Last active
May 5, 2017 05:42
-
-
Save jeanlucaslima/04144258d421177f21c41f26b14aa607 to your computer and use it in GitHub Desktop.
Revisions
-
jeanlucaslima revised this gist
May 5, 2017 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,7 @@ // Estranho bug de performance encontrado por [andreasgal](https://github.com/andreasgal) // // Comportamento esperado: foo() e bar() terem ao menos performance similar // Comportamento observado: foo() tem performance diferente que bar() dependendo da máquina // // A única diferença entre foo() e bar() é a ordem de declaração dos valores dentro do vetor // Não sei explicar o motivo desse comportamento -
jeanlucaslima revised this gist
May 5, 2017 . 1 changed file with 5 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,9 @@ // Estranho bug de performance encontrado por [andreasgal](https://github.com/andreasgal) // // Comportamento esperado: foo() e bar() terem ao menos performance similar // Comportamento observado: foo() tem performance até 4x maior que bar() depndendo da máquina // // A única diferença entre foo() e bar() é a ordem de declaração dos valores dentro do vetor // Não sei explicar o motivo desse comportamento var A = []; -
jeanlucaslima revised this gist
May 5, 2017 . 1 changed file with 4 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,7 @@ // Estranho bug de performance encontrado por [andreasgal](https://github.com/andreasgal) // A única diferença entre foo() e bar() é a ordem de declaração do vetor // Não sei explicar o motivo desse comportamento var A = []; function foo() { var J = [124, 564, 456, 1000]; -
jeanlucaslima revised this gist
May 5, 2017 . 1 changed file with 11 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -14,5 +14,15 @@ function bar() { } } var perf_foo_t0 = performance.now(); foo(); var perf_foo_t1 = performance.now(); var perf_bar_t0 = performance.now(); bar(); var perf_bar_t1 = performance.now(); console.log("Call to bar took " + (perf_bar_t1 - perf_bar_t0) + " milliseconds."); console.log("Call to foo took " + (perf_foo_t1 - perf_foo_t0) + " milliseconds."); console.log("foo was " + (perf_foo_t1 - perf_foo_t0)/(perf_bar_t1 - perf_bar_t0) + " times faster than bar."); -
jeanlucaslima revised this gist
May 5, 2017 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -8,7 +8,7 @@ function foo() { var B = []; function bar() { var K = [1000, 124, 564, 456]; for (var j = 0; j < 5000000; j++) { B[K[j % 4]] = j; } -
jeanlucaslima created this gist
May 5, 2017 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,18 @@ var A = []; function foo() { var J = [124, 564, 456, 1000]; for (var i = 0; i < 5000000; i++) { A[J[i % 4]] = i; } } var B = []; function bar() { var K = [1000, 564, 456]; for (var j = 0; j < 5000000; j++) { B[K[j % 4]] = j; } } foo(); bar();