jsPerf.app is an online JavaScript performance benchmark test runner & jsperf.com mirror. It is a complete rewrite in homage to the once excellent jsperf.com now with hopefully a more modern & maintainable codebase.
jsperf.com URLs are mirrored at the same path, e.g:
https://jsperf.com/negative-modulo/2
Can be accessed at:
https://jsperf.app/negative-modulo/2
Testing if the perf hit for Object.keys(..).forEach(..)
is enough to matter as compared to for-in
.
<script>
</script>
function iterate1() {
var ret = "";
for (var i in obj) {
if (obj.hasOwnProperty(i)) {
ret += obj[i];
}
}
return ret;
}
function iterate2() {
var ret = "";
Object.keys(obj).forEach(function(key){
ret += obj[key];
});
return ret;
}
var tmp;
var obj = {
background_color: "#cccccc",
custom_icon_data: "{}",
default_folder_id: 1,
dial_columns: 6,
dial_width: 70,
drag_and_drop: "true",
enable_sync: "false",
folder_color: "#888888",
force_http: "true",
show_advanced: "false",
show_folder_list: "true",
show_new_entry: "true",
show_options_gear: "true",
show_subfolder_icons: "true",
thumbnailing_service: "http://immediatenet.com/t/l3?Size=1280x1024&URL=[URL]"
};
tmp = "";
Ready to run.
Test | Ops/sec | |
---|---|---|
for-in |
| ready |
Object.keys(..).forEach(..) |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.