[Pkg-javascript-commits] [ltx] 221/469: browser_benchmark: uses requestAnimationFrame

Jonas Smedegaard dr at jones.dk
Wed Aug 31 13:03:06 UTC 2016


This is an automated email from the git hooks/post-receive script.

js pushed a commit to branch master
in repository ltx.

commit a452e70597f6589f895eec3710824e1b55d03282
Author: Astro <astro at spaceboyz.net>
Date:   Tue Mar 20 02:16:44 2012 +0100

    browser_benchmark: uses requestAnimationFrame
---
 benchmark/browser_benchmark.js | 49 +++++++++++++++++++++---------------------
 package.json                   |  1 +
 2 files changed, 25 insertions(+), 25 deletions(-)

diff --git a/benchmark/browser_benchmark.js b/benchmark/browser_benchmark.js
index 11fd8d4..bc8a175 100644
--- a/benchmark/browser_benchmark.js
+++ b/benchmark/browser_benchmark.js
@@ -1,6 +1,7 @@
 var ltx = require("ltx");
 var strophe = require('Strophe.js');
 var util = require('util');
+var requestAnimationFrame = require('request-animation-frame').requestAnimationFrame;
 
 function now() {
     return new Date().getTime();
@@ -90,32 +91,30 @@ messages[3] += "</message>";
 var iteration = 0;
 function runTests() {
     iteration++;
-    for(var i = 0; i < 10; i++) {
-	tests.forEach(function(test) {
-	    for(var j = 0; j < messages.length; j++) {
-		var parsed, serialized;
-		test.record('parse' + j, function() {
-		    parsed = test.parse(messages[j]);
-		});
-		test.record('serialize' + j, function() {
-		    serialized = test.serialize(parsed);
-		});
-		test.record('traverse' + j, function() {
-		    test.traverse(parsed);
-		});
-	    }
-	});
-    }
+    tests.forEach(function(test) {
+	for(var j = 0; j < messages.length; j++) {
+	    var parsed, serialized;
+	    test.record('parse' + j, function() {
+		parsed = test.parse(messages[j]);
+	    });
+	    test.record('serialize' + j, function() {
+		serialized = test.serialize(parsed);
+	    });
+	    test.record('traverse' + j, function() {
+		test.traverse(parsed);
+	    });
+	}
+    });
+
+    document.body.innerHTML = "<style>.parse0, .parse1, .parse2, .parse3 { color: red; } .serialize1, .serialize2, .serialize3, .serialize4 { color: blue; }</style>\n" +
+	"<h1>Iteration " + iteration + "<h1>\n";
+    tests.forEach(function(test) {
+	document.body.innerHTML += test.report() + "<br>";
+    });
+
+    requestAnimationFrame(runTests);
 }
 
 setTimeout(function() {
-    window.setInterval(function() {
-	runTests();
-
-	document.body.innerHTML = "<style>.parse0, .parse1, .parse2, .parse3 { color: red; } .serialize1, .serialize2, .serialize3, .serialize4 { color: blue; }</style>\n" +
-	    "<h1>Iteration " + iteration + "<h1>\n";
-	tests.forEach(function(test) {
-	    document.body.innerHTML += test.report() + "<br>";
-	});
-    }, 1);
+    runTests();
 }, 1000);
diff --git a/package.json b/package.json
index c9dba09..ea8463b 100644
--- a/package.json
+++ b/package.json
@@ -22,6 +22,7 @@
 ,"devDependencies": {"vows": ">=0.5.12"
 		    ,"sax": "0.3.5"
 		    ,"Strophe.js": "https://github.com/metajack/strophejs/tarball/master"
+		    ,"request-animation-frame": ">=0.1.0"
 		    }
 ,"scripts": {"test":"vows --spec"}
 }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/ltx.git



More information about the Pkg-javascript-commits mailing list