Skip to content

Commit

Permalink
Add a few microbenchmarks for property caching
Browse files Browse the repository at this point in the history
  • Loading branch information
svaarala committed Feb 12, 2017
1 parent b9eb3f7 commit 65ae169
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 0 deletions.
20 changes: 20 additions & 0 deletions tests/perf/test-prop-read-long-inherit.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
function test() {
var i;
var obj;

obj = { foo: 123 };
for (i = 0; i < 100; i++) {
obj = Object.create(obj);
 }

for (i = 0; i < 1e7; i++) {
void obj.foo;
}
}

try {
test();
} catch (e) {
print(e.stack || e);
throw e;
}
14 changes: 14 additions & 0 deletions tests/perf/test-prop-read-math-pi.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
function test() {
var i;

for (i = 0; i < 1e7; i++) {
void Math.PI
}
}

try {
test();
} catch (e) {
print(e.stack || e);
throw e;
}
23 changes: 23 additions & 0 deletions tests/perf/test-prop-write-long-inherit.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
function test() {
var i;
var obj;

obj = { foo: 123 };
for (i = 0; i < 100; i++) {
obj = Object.create(obj);
 }

for (i = 0; i < 1e7; i++) {
// Because a write always causes an own property to be created,
// there's no difference between a shallow and deep object except
// on the very first write.
obj.foo = 123;
}
}

try {
test();
} catch (e) {
print(e.stack || e);
throw e;
}

0 comments on commit 65ae169

Please sign in to comment.