Created
April 18, 2018 16:22
-
-
Save Leask/5fbf52db3f1311c403f86ba3ac5f4482 to your computer and use it in GitHub Desktop.
Simple Javascript speed testing
This file contains hidden or 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
let a = [ | |
[1, 2, 3, 4], | |
[1, 2, 3, 4], | |
[1, 2, 3, 4], | |
[1, 2, 3, 4], | |
]; | |
let t1 = new Date().getTime(); | |
for (let i = 0; i < 1000000; i++) { | |
for (let j in a) { | |
for (let k in a[j]) { | |
let x1 = a[j]; | |
let x2 = a[j]; | |
let x3 = a[j]; | |
let x4 = a[j]; | |
// console.log(x); | |
} | |
} | |
} | |
let t2 = new Date().getTime(); | |
console.log(t2 - t1); | |
for (let i = 0; i < 1000000; i++) { | |
for (let j in a) { | |
let y = a[j]; | |
for (let k in y) { | |
let x1 = y[k]; | |
let x2 = y[k]; | |
let x3 = y[k]; | |
let x4 = y[k]; | |
// console.log(x); | |
} | |
} | |
} | |
let t3 = new Date().getTime(); | |
console.log(t3 - t2); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment