Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function Foobar() {
- this.abc = 1;
- this.test = function (n) {
- this.abc = n;
- };
- this.runTest = function (N) {
- console.time('foobar speed');
- for (var i = 0; i < N; ++i) {
- this.test(i);
- }
- console.timeEnd('foobar speed');
- };
- }
- var N = 10000000;
- var a = new Foobar(), b = new Foobar(), c = new Foobar();
- a.runTest(N); // foobar speed: 18ms
- b.runTest(N); // foobar speed: 125ms
- c.runTest(N); // foobar speed: 122ms
- a.runTest(N); // foobar speed: 14ms
- b.runTest(N); // foobar speed: 117ms
- c.runTest(N); // foobar speed: 128ms
Advertisement
Add Comment
Please, Sign In to add comment