-
Notifications
You must be signed in to change notification settings - Fork 515
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a few microbenchmarks for property caching
- Loading branch information
Showing
3 changed files
with
57 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
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; | ||
} |
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,14 @@ | ||
function test() { | ||
var i; | ||
|
||
for (i = 0; i < 1e7; i++) { | ||
void Math.PI | ||
} | ||
} | ||
|
||
try { | ||
test(); | ||
} catch (e) { | ||
print(e.stack || e); | ||
throw e; | ||
} |
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,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; | ||
} |