aboutsummaryrefslogtreecommitdiffstats
path: root/perf/testUtils.js
diff options
context:
space:
mode:
authorIgor Minar2010-12-21 17:13:07 -0800
committerIgor Minar2010-12-22 14:16:36 -0800
commite3ddc2bcc48ba6160455c4ffe35df87715c05693 (patch)
treeba60df45585e778958804fb92b14f1dcbd0123ae /perf/testUtils.js
parentd11088eb430ef7f0b444888517868ba880610f6b (diff)
downloadangular.js-e3ddc2bcc48ba6160455c4ffe35df87715c05693.tar.bz2
simple perf testing harness with JSON parsing tests
- all tests should be under perf/ - all payloads should be under perf/data - run tests with ./server.sh + ./test-perf.sh We still lack a way to compare results against a baseline, but this is better than nothing.
Diffstat (limited to 'perf/testUtils.js')
-rw-r--r--perf/testUtils.js20
1 files changed, 20 insertions, 0 deletions
diff --git a/perf/testUtils.js b/perf/testUtils.js
new file mode 100644
index 00000000..ca016c31
--- /dev/null
+++ b/perf/testUtils.js
@@ -0,0 +1,20 @@
+if (window.jstestdriver) {
+ jstd = jstestdriver;
+ dump = angular.bind(jstd.console, jstd.console.log);
+}
+
+function time(fn, times) {
+ times = times || 1;
+
+ var i,
+ start,
+ duration = 0;
+
+ for (i=0; i<times; i++) {
+ start = Date.now();
+ fn();
+ duration += Date.now() - start;
+ }
+
+ return duration;
+} \ No newline at end of file