JSON vs. for

JavaScript performance comparison

Test case created

Preparation code

<script>var myObj = {
    deleteProject: function() {
        var project = this.get('readyToDelete');
        this.set('deleting', true);
        log('TEST', project.id)
        this.server.send('deleteProject', project.id.toString(), function() {
            this.clearMessages();
            this.set('projectDeleted', true);
            this.removeDeletedProject();
        }.bind(this), function() {
            this.clearMessages();
            this.set('deletionFailed', true)
        }.bind(this));
    },
    clearMessages: function() {
        this.setProperties({
            projectDeleted: false,
            deletionFailed: false,
            deleting: false
        });
    },
    removeDeletedProject: function() {
        var id = this.get('readyToDelete').id;
       
    }
}</script>

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
JSON
var res = JSON.parse(JSON.stringify(myObj));
pending…
for
var res = {};
for(var prop in myObj) {
   if(myObj.hasOwnProperty(prop)) {
      res[prop] = myObj[prop];
   }
}
pending…

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

Compare results of other browsers

0 comments

Add a comment