[nodejs] Re: Buffer vs String

2014-09-16 Thread Andrey
Strings are very optimized in v8, so just replacing hot path string with buffer does not always help - benchmark first, ideally at a very low level ( statistical profiler / dtrace / generated assembly / irhydra ). For example, if you do `content += chunk` in a loop you are likely not copying st

[nodejs] Re: Buffer vs String

2014-09-15 Thread mscdex
On Sunday, September 14, 2014 8:52:36 PM UTC-4, Michael Monashev wrote: > > I rewite some code from Strings to Buffers with zero data copying (I > use slice). But the new code was 10 times slower! I Buffer slower than > String? > It'd be helpful if you also posted the relevant code. -- Job

[nodejs] Re: Buffer vs String

2014-09-15 Thread Floby
Barrier crossing between JS and C++ is slow. Buffer is implemented by Node.js and therefore each call to .slice() is expensive because of that barrier crossing. I advise you measure and choose the best option for your use case. On Monday, 15 September 2014 02:52:36 UTC+2, Michael Monashev wrote: