visionmedia/ejs — pull request #123 by fengmk2 (2013-06-20 10:44:28+00:00)
Title: add `options.parsePlus`: Use `buf +=` instead of `buf.push()`

Add a new `parse` function, using `buf +` instead of `buf.push()` for string concat.

It will improve performance.

My benchmark result:

```bash
$ node benchmark2.js

renderNoCompileDebugNoWith source:

var buf = [];
buf.push('');1; if (locals.user) { ; buf.push('\n

hello, ', escape((2, locals.user.name )), ' ', escape((2, locals.user.not_exists )), '

\n

', (3, locals.user.title ), '

\n');4; } ; buf.push('');
return buf.join('');
--------------------------------------------------------------
render_ParsePlus_NoCompileDebugNoWith source:

var buf = "";
buf += '';1; if (locals.user) { ; buf += '\n

hello, ' + escape((2, locals.user.name )) + ' ' + escape((2, locals.user.not_exists )) + '

\n

' + (3, locals.user.title ) + '

\n';4; } ; buf += '';
return buf;
--------------------------------------------------------------
render:

hello, fengmk2 undefined

renderNoWith:

hello, fengmk2 undefined

renderNoCompileDebug:

hello, fengmk2 undefined

renderNoCompileDebugNoWith:

hello, fengmk2 undefined

render_ParsePlus_NoWith:

hello, fengmk2 undefined

undefined

render_ParsePlus:

hello, fengmk2 undefined

undefined

render_ParsePlus_NoCompileDebugNoWith:

hello, fengmk2 undefined

undefined

render() x 150,062 ops/sec ±0.93% (96 runs sampled)
renderNoCompileDebug() x 173,700 ops/sec ±1.32% (90 runs sampled)
renderNoWith() x 315,558 ops/sec ±1.19% (91 runs sampled)
renderNoCompileDebugNoWith() x 354,070 ops/sec ±1.51% (90 runs sampled)
render_ParsePlus() x 183,668 ops/sec ±0.76% (96 runs sampled)
render_ParsePlus_NoWith() x 547,998 ops/sec ±0.94% (93 runs sampled)
render_ParsePlus_NoCompileDebugNoWith() x 608,255 ops/sec ±0.92% (95 runs sampled)
Fastest is render_ParsePlus_NoCompileDebugNoWith()
```