HTML and CSS Reference
In-Depth Information
if (times[label] > max) {
max = times[label];
slowest = label;
var lis = view.getElementsByTagName("li");
var fastRegexp = new RegExp("^" + fastest + ":");
var slowRegexp = new RegExp("^" + slowest + ":");
for(vari=0,l=lis.length; i < l; i++) {
if (slowRegexp.test(lis[i].innerHTML)) {
lis[i].style.color = "#c00";
if (fastRegexp.test(lis[i].innerHTML)) {
lis[i].style.color = "#0c0";
}, 15);
// Updated benchmark function
function benchmark (name, tests, iterations) {
iterations = iterations
times = {};
var view = init(name);
runTests(tests, view, iterations);
To further enhance benchmark we could decouple the DOM manipulation
that displays results to allow for alternate report generators. This would also allow us
to benchmark code in environments without a DOM, such as server-side JavaScript
4.2.2 Profiling and Locating Bottlenecks
Firebug, the web developer add-on for Firefox, offers a profiler that can profile
code as it runs. For instance, we can launch a live site, start the profiler and click a
link that triggers a script. After the script finishes we stop the profiler. At this point
the profile report will show us a breakdown of all functions run, along with how
much time was spent on each of them. Many times the number of functions run
to perform some task can in itself be valuable information that points us to overly
Search WWH ::

Custom Search