Skip to content

Instantly share code, notes, and snippets.

@TheoOkafor
Last active January 20, 2021 21:48
Show Gist options
  • Save TheoOkafor/3347c8283e606ede6ccab9b3916afc53 to your computer and use it in GitHub Desktop.
Save TheoOkafor/3347c8283e606ede6ccab9b3916afc53 to your computer and use it in GitHub Desktop.
test the runtime with and without console.log statement
const testRuntimeWithConsole = () => {
console.time('====== WITH CONSOLE.LOG ====='); // the start time
let result = 0;
for (let i = 0; i < 100; i += 1) {
result += i;
console.log(result); // log the result to the console
}
console.timeEnd('====== WITH CONSOLE.LOG ====='); // the end time
return result;
};
const testRuntimeWithoutConsole = () => {
console.time('====== WITHOUT CONSOLE.LOG ====='); // the start time
let result = 0;
for (let i = 0; i < 100; i += 1) {
result += i;
}
console.timeEnd('====== WITHOUT CONSOLE.LOG ====='); // the end time
return result;
};
testRuntimeWithConsole();
testRuntimeWithoutConsole();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment