Last active
January 20, 2021 21:48
-
-
Save TheoOkafor/3347c8283e606ede6ccab9b3916afc53 to your computer and use it in GitHub Desktop.
test the runtime with and without console.log statement
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
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