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 Jan 30, 2017
1 parent 0c6f100 commit 809be71
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 809be71

Please sign in to comment.