Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Benchmark javascript execution with callback functions

Benchmark javascript execution with callback functions

Problem

I have some JavaScript that I'm trying to benchmark the time it takes to execute.

The problem with this is that the for loop completes quickly, meanwhile the Execution of the Item.save() method is not yet complete.

Any suggestions how to time this that takes into account the full execution time within the contents of the loop?

Thank you!

var start = new Date().getTime();
var Item = new Item();
for (i = 0; i 

EDIT: This is on a nodejs server.

Problem courtesy of: dzm

Solution

Just use Chrome's profiling tools. They give you total insight into exactly how much CPU time every function call on your page is taking up:

http://code.google.com/chrome/devtools/docs/cpu-profiling-files/two_profiles.png


For Node, you can try node-inspector's experimental profiler.

Solution courtesy of: josh3736

Discussion

View additional discussion.



This post first appeared on Node.js Recipes, please read the originial post: here

Share the post

Benchmark javascript execution with callback functions

×

Subscribe to Node.js Recipes

Get updates delivered right to your inbox!

Thank you for your subscription

×