Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4875)

Unified Diff: chrome/test/data/third_party/spaceport/js/util/bench.js

Issue 10154006: Add test data for spaceport benchmark. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/test/data/third_party/spaceport/js/util/bench.js
diff --git a/chrome/test/data/third_party/spaceport/js/util/bench.js b/chrome/test/data/third_party/spaceport/js/util/bench.js
new file mode 100644
index 0000000000000000000000000000000000000000..588ec3c1c205ddbac72990fe4818f535a2410632
--- /dev/null
+++ b/chrome/test/data/third_party/spaceport/js/util/bench.js
@@ -0,0 +1,26 @@
+define([ ], function () {
+ // Benchmarks fn until maxTime ms has passed. Returns approximate number
+ // of operations performed in that time ('score').
+ function bench(maxTime, fn) {
+ if (typeof fn !== 'function') {
+ throw new TypeError('Argument must be a function');
+ }
+
+ var operationCount = 0;
+ var startTime = Date.now();
+ var endTime;
+ while (true) {
+ fn(operationCount);
+ ++operationCount;
+
+ endTime = Date.now();
+ if (endTime - startTime >= maxTime) {
+ break;
+ }
+ }
+
+ return operationCount / (endTime - startTime) * maxTime;
+ }
+
+ return bench;
+});
« no previous file with comments | « chrome/test/data/third_party/spaceport/js/unrequire.js ('k') | chrome/test/data/third_party/spaceport/js/util/benchAsync.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698