new vs Object.create 1 (v20)

Revision 20 of this benchmark created by jajajaj on


Preparation HTML

<script>
var count = 100;

var real = "";
for(var i=0; i<count;i++) {
real += '\nthis[\'f'+i+'\'] = \'' + (i%2 ? 'node' : 'postgres') +'\';'
}

var fnbody = "return {";
for(var i=0; i<count;i++) {
fnbody += '\n\'f'+i+'\':\'' + (i%2 ? 'node' : 'postgres') +'\','
}
fnbody.trim(',');
fnbody += '}';

var ctorbody = ""
for(var i=0; i<count;i++) {
ctorbody += '\nrow[\'f'+i+'\'] = \'' + (i%2 ? 'node' : 'postgres') +'\';'
}
ctorbody.trim('\n return row;');

var ctor1 = new Function("row", ctorbody);

var ctor2 = new Function(fnbody);

var realctor = new Function(real);

</script>

Test runner

Ready to run.

Testing in
TestOps/sec
new
var object = new realctor();
ready
ctor1
var object = ctor1({});
ready
ctor2
var object = new ctor2();
ready

Revisions

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