> On Dec 6, 2015, at 8:57 AM, jeongsik woo <realjays1...@gmail.com> wrote:
> 
> Hi. I installed node.js 4.2.1(argon).
> I noticed new key 'let' of ES6. 
> (https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Statements/let)
> 
> I understood that let use lower memory than 'var'. because let has block 
> scope, but 'var' has function scope.
> 
> So I tested memory usage of var and let.
> 
> But test result refer to 'var' uses lower memory than 'let'.
> differences of rss, heapTotal, heapUsed value of 'let' is bigger than 'var'.
> 
> do I misunderstand 'let'? 
> 
> Sorry for my english writting, I am english newbie. 
> 
> below is my test code.

So there's enough complexity in V8 that a microbenchmark like yours may not 
show off real world scenarios. There are some differences: with `let`, you're 
making a new variable every time; with `var` you're re-using that. That means 
that there may be cases that the optimizer could convert back (where the effect 
won't leak), but those probably have to be written. I don't know the state of 
that in the optimizer, or if that's even an interesting optimization.

And then there's dead code elimination and all kinds of other optimizer tricks.

Then you've got a tight loop making garbage, and the garbage collector has to 
run periodically. So that will show a higher RSS, but it may not actually 
affect a real program unless your real program is at tight loop.

TL;DR: You're probably not measuring what you think you're measuring. if you 
are measuring that, what you're measuring is likely not relevant to results.

Aria

-- 
Job board: http://jobs.nodejs.org/
New group rules: 
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to nodejs+unsubscr...@googlegroups.com.
To post to this group, send email to nodejs@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nodejs/0E805453-11CF-4E5D-A708-A0933F04FEEC%40dinhe.net.
For more options, visit https://groups.google.com/d/optout.

Attachment: smime.p7s
Description: S/MIME cryptographic signature

Reply via email to