Skip to content

Instantly share code, notes, and snippets.

@searls
Created January 25, 2012 14:56
Show Gist options
  • Select an option

  • Save searls/1676629 to your computer and use it in GitHub Desktop.

Select an option

Save searls/1676629 to your computer and use it in GitHub Desktop.
just used this for profiling jasmine specs (trying to isolate slow specs)
//outside of any describe() block so they run for every single spec.
beforeEach(function() {
window.timings = window.timings || []
timings.push({
startTime: new Date(),
spec: this
});
});
afterEach(function() {
_(timings).last()["endTime"] = new Date();
});
//laster from the browser console (using Underscore.js)
_(timings).sortBy(function(timing){ timing.elapsedMs = timing.endTime - timing.startTime; return timing.elapsedMs; });
//^ the above results will be sorted fastest-to-slowest
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment