Created
July 16, 2016 13:46
-
-
Save cswl/741078318d2e608732f6a9b51e6b497c to your computer and use it in GitHub Desktop.
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
var microtime = require('microtime') | |
// @microtimer | |
// function for_let_loop() .. okay no :( | |
{ //block scoping :D | |
const start = microtime.now(); | |
for(let i = 0; i < 1e8; ++i){} | |
const end = microtime.now(); | |
console.log(`for_let_loop took ${end-start}us`); | |
} | |
{ //block scoping :D | |
const start = microtime.now(); | |
let i = 0; | |
for(; i < 1e8; ++i){} | |
const end = microtime.now(); | |
console.log(`for_let_outside took ${end-start}us`); | |
} | |
{ //block scoping :D | |
const start = microtime.now(); | |
let i = 0; | |
for(; i < 1e8; ++i){const k=i;} | |
const end = microtime.now(); | |
console.log(`for_let_outside_const_inside took ${end-start}us`); | |
} | |
{ //block scoping :D | |
const start = microtime.now(); | |
let i = 0; | |
for(; i < 1e8; ++i){let k=i;} | |
const end = microtime.now(); | |
console.log(`for_let_outside_let_inside took ${end-start}us`); | |
} | |
// var isn't block scoped anyway :| | |
const start = microtime.now(); | |
for(var i = 0; i < 1e8; ++i){} | |
const end = microtime.now(); | |
console.log(`for_var_loop took ${end-start}us`); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment