Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Harmony Proxy Benchmark
var noop = function(){};
var obj = {
'1':function(){ console.log(1) },
'10':function(){ console.log(10) },
'100':function(){ console.log(100) },
'1000':function(){ console.log(1000) },
'10000':function(){ console.log(10000) }
};
console.time('checking');
for(var i = 0; i < 10000000; i += 1){
if(i in obj){
obj[i]();
} else {
noop();
}
}
console.timeEnd('checking');
var proxy = Proxy.create({
getOwnPropertyDescriptor: function(name){ return Object.getOwnPropertyDescriptor(obj); },
getPropertyDescriptor: function(name){ return Object.getOwnPropertyDescriptor(obj); },
getOwnPropertyNames: function(){ return Object.getOwnPropertyNames(obj); },
getPropertyNames: function(){ return Object.getOwnPropertyNames(obj); },
get: function(recv, name){ return obj[name] || noop; }
}, obj);
console.time('proxy');
for(var i = 0; i < 10000000; i += 1){
proxy[i]();
}
console.timeEnd('proxy');
$ node --harmony-proxies proxy_bench.js
1
10
100
1000
10000
checking: 418ms
1
10
100
1000
10000
proxy: 4680ms
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.