if/substring

Benchmark created on


Setup

var data = {"a":"one", "b":"two", "c":"three", "d":"four", "e":"five"};
    
    var postString = "";
    
    var key;

Test runner

Ready to run.

Testing in
TestOps/sec
if
postString = "";
for (key in data) {
    if(postString !== "") {
        postString += "&";
    }
    postString += key + "=" + data[key];
}
ready
substring
postString = "";
for (key in data) {
    postString += "&" + key + "=" + data[key];
}
postString = postString.substring(1);
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.