Created
February 27, 2019 12:10
-
-
Save poeschko/7e94a825f5be4fb509ee54e27b4f18c0 to your computer and use it in GitHub Desktop.
Performance of Smi vs. floating-point number representation
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
function copyAndIncrement(arr) { | |
const copy = arr.slice(); | |
copy[0] += 1; | |
return copy; | |
} | |
function spoil() { | |
const objThatSpoilsEverything = {}; | |
objThatSpoilsEverything.value = 1.5; | |
} | |
function run() { | |
spoil(); | |
const obj = {}; | |
obj.value = 1; | |
let arr = []; | |
for (let i = 0; i < 100; ++i) { | |
arr.push(obj.value); | |
} | |
for (let i = 0; i < 10000000; ++i) { | |
arr = copyAndIncrement(arr); | |
} | |
} | |
run(); |
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
function copyAndIncrement(arr) { | |
const copy = arr.slice(); | |
copy[0] += 1; | |
return copy; | |
} | |
function run() { | |
const obj = {}; | |
obj.value = 1; | |
let arr = []; | |
for (let i = 0; i < 100; ++i) { | |
arr.push(obj.value); | |
} | |
for (let i = 0; i < 10000000; ++i) { | |
arr = copyAndIncrement(arr); | |
} | |
} | |
run(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@poeschko Can you add the contents of the
examples.bat
file from the command line example: