Last active
August 2, 2017 19:37
-
-
Save hdgarrood/963eb75bc566074300e438996eeda11e to your computer and use it in GitHub Desktop.
perf impact of reordering declaration ref list
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
var master = [15.985, 15.774, 16.664, 16.111, 15.889, 15.603, 15.598, 15.690, 15.602, 16.159]; | |
var reordered = [15.831, 16.182, 16.519, 15.383, 15.936, 15.888, 15.645, 15.775, 15.749, 16.076]; | |
function mean(arr) { | |
return arr.reduce(function(x,y) { return x + y; }) / arr.length; | |
} | |
function variance(arr) { | |
var m = mean(arr); | |
return mean(arr.map(function(x) { | |
var diff = x - m; | |
return diff*diff; | |
})); | |
} | |
function stddev(arr) { | |
return Math.sqrt(variance(arr)); | |
} | |
function summarise(title, arr) { | |
console.log(title + ":"); | |
console.log("mean: " + mean(arr) + "s"); | |
console.log("std dev: " + stddev(arr) + "s"); | |
} | |
summarise("master", master); | |
summarise("reordered", reordered); |
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
*** current master *** | |
real 0m15.985s | |
user 1m24.916s | |
sys 0m26.712s | |
real 0m15.774s | |
user 1m25.188s | |
sys 0m25.840s | |
real 0m16.664s | |
user 1m29.352s | |
sys 0m27.292s | |
real 0m16.111s | |
user 1m25.568s | |
sys 0m27.128s | |
real 0m15.889s | |
user 1m25.332s | |
sys 0m26.176s | |
real 0m15.603s | |
user 1m23.188s | |
sys 0m26.628s | |
real 0m15.598s | |
user 1m22.132s | |
sys 0m27.304s | |
real 0m15.690s | |
user 1m23.196s | |
sys 0m26.740s | |
real 0m15.602s | |
user 1m24.196s | |
sys 0m25.564s | |
real 0m16.159s | |
user 1m25.284s | |
sys 0m27.264s | |
*** this branch *** | |
real 0m15.831s | |
user 1m24.448s | |
sys 0m26.440s | |
real 0m16.182s | |
user 1m25.628s | |
sys 0m27.200s | |
real 0m16.519s | |
user 1m26.384s | |
sys 0m28.056s | |
real 0m15.383s | |
user 1m21.764s | |
sys 0m26.812s | |
real 0m15.936s | |
user 1m25.824s | |
sys 0m25.820s | |
real 0m15.888s | |
user 1m25.448s | |
sys 0m25.952s | |
real 0m15.645s | |
user 1m23.276s | |
sys 0m26.700s | |
real 0m15.775s | |
user 1m24.872s | |
sys 0m25.908s | |
real 0m15.749s | |
user 1m25.428s | |
sys 0m25.632s | |
real 0m16.076s | |
user 1m24.292s | |
sys 0m27.124s | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Output: