Skip to content

Instantly share code, notes, and snippets.

@poeschko
Created February 27, 2019 12:10
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save poeschko/7e94a825f5be4fb509ee54e27b4f18c0 to your computer and use it in GitHub Desktop.
Performance of Smi vs. floating-point number representation
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();
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();
@Stamo-Gochev
Copy link

@poeschko Can you add the contents of the examples.bat file from the command line example:

multitime -n 100 -s 1 -b examples.bat

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment