From 85cc251adffa0ade78d3163882a79485692b5c25 Mon Sep 17 00:00:00 2001 From: Mike Gerwitz Date: Thu, 27 Mar 2014 22:49:50 -0400 Subject: [PATCH] Added baseline tests for prototype method and function call invocation --- test/perf/perf-class-invoke-method.js | 29 +++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/test/perf/perf-class-invoke-method.js b/test/perf/perf-class-invoke-method.js index bb4f24a..01f185e 100644 --- a/test/perf/perf-class-invoke-method.js +++ b/test/perf/perf-class-invoke-method.js @@ -105,3 +105,32 @@ common.test( function() // run the same test internally foo.testInternal(); + +// allows us to compare private method invocation times with method +// invocations on a conventional prototype (the increment of `i` is to +// ensure that the function is not optimized away) +( function() +{ + var p = function() {}; + p.prototype.foo = function() { i++ }; + var o = new p(); + + common.test( function() + { + var i = count; + while ( i-- ) o.foo(); + }, count, '[baseline] Invoke method on prototype' ); +} )(); + + +// compare with plain old function invocation +( function() +{ + var f = function() { i++ }; + common.test( function() + { + var i = count; + while ( i-- ) f(); + }, count, '[baseline] Invoke function' ); +} )(); +