Prototyping speed test (prototyping 19,6x faster in node-webkit)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE HTML> | |
<html> | |
<head> | |
<title>Test Prototyping</title> | |
<script language="javascript"> | |
var X,Y, x,y, i, intNow; | |
X = function() {}; | |
X.prototype.message = function(s) { var mymessage = s + "";} | |
X.prototype.addition = function(i,j) { return (i *2 + j * 2) / 2; } | |
Y = function() { | |
this.message = function(s) { var mymessage = s + "";} | |
this.addition = function(i,j) { return (i *2 + j * 2) / 2; } | |
}; | |
intNow = (new Date()).getTime(); | |
for (i = 0; i < 1000000; i++) { | |
y = new Y(); | |
y.message('hi'); | |
y.addition(i,2) | |
} | |
console.log((new Date()).getTime() - intNow); // without prototyping | |
intNow = (new Date()).getTime(); | |
for (i = 0; i < 1000000; i++) { | |
x = new X(); | |
x.message('hi'); | |
x.addition(i,2) | |
} | |
console.log((new Date()).getTime() - intNow); // with prototyping | |
</script> | |
</head> | |
<body> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Milliseconds on my node-webkit 0.6.2 / Linux Debian 64bit: