-
Notifications
You must be signed in to change notification settings - Fork 653
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a benchmark exercising property lookups in the immediate prototype.
Summary: This diff adds a microbenchmark stressing property lookups satisfied in an object's immediate prototype. This provides a baseline for a subsequent diff that optimizes such accesses. Reviewed By: avp Differential Revision: D65350534 fbshipit-source-id: 12b1dfdfbc7219d0427b64ca944c7f94d0079368
- Loading branch information
1 parent
5943fa4
commit 685b9b0
Showing
2 changed files
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
benchmarks/bench-runner/resource/test-suites/micros/protoCache.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
var start = new Date(); | ||
var val = (function () { | ||
var proto = {x: 7}; | ||
var o = Object.create(proto); | ||
|
||
function access(o) { | ||
'noinline' | ||
// 50 accesses, all found in the proto. | ||
return o.x + o.x + o.x + o.x + o.x | ||
+ o.x + o.x + o.x + o.x + o.x | ||
+ o.x + o.x + o.x + o.x + o.x | ||
+ o.x + o.x + o.x + o.x + o.x | ||
+ o.x + o.x + o.x + o.x + o.x | ||
+ o.x + o.x + o.x + o.x + o.x | ||
+ o.x + o.x + o.x + o.x + o.x | ||
+ o.x + o.x + o.x + o.x + o.x | ||
+ o.x + o.x + o.x + o.x + o.x | ||
+ o.x + o.x + o.x + o.x + o.x; | ||
} | ||
var numIter = 10000000; | ||
var sum = 0; | ||
for (var i = 0; i < numIter; i++) { | ||
sum += access(o); | ||
} | ||
return sum; | ||
}()); | ||
var end = new Date(); | ||
print("val: " + val); | ||
print("Time: " + (end - start)); |