Created
October 13, 2020 21:05
-
-
Save wentout/1c857b77721663d82bad07ef2d89e899 to your computer and use it in GitHub Desktop.
Prototype Chain Deepness test.
This file contains hidden or 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
| 'use strict'; | |
| const MAX_NUM = 1000; | |
| global.m = []; | |
| global.start = Date.now(); | |
| global.current = { | |
| name: 'root' | |
| }; | |
| const makeNextEls = function () { | |
| let name, el; | |
| const pointer = global.current; | |
| name = `idx_${ global.m.length }`; | |
| el = { | |
| name, | |
| [name]: true, | |
| parent: pointer, | |
| get self () { | |
| return el; | |
| } | |
| }; | |
| Object.setPrototypeOf(el, pointer); | |
| global.current = el; | |
| global.m.push(el); | |
| if (global.m.length < MAX_NUM) { | |
| console.log(global.m.length, name, (Date.now() - global.start) / 1000); | |
| setTimeout(() => { | |
| makeNextEls(); | |
| }, 0); | |
| } else { | |
| console.log('finished', global.m.length, (Date.now() - global.start) / 1000); | |
| } | |
| }; | |
| makeNextEls(global.current); | |
| setInterval(() => { | |
| console.log('ended'); | |
| }, 1000000); | |
| debugger; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment