diff options
author | isaacs <i@izs.me> | 2013-02-12 01:37:24 +0400 |
---|---|---|
committer | isaacs <i@izs.me> | 2013-02-20 02:14:32 +0400 |
commit | cc38528acf976c6f10da45b1d824f86444067fb1 (patch) | |
tree | e09a9555c2e2524ef51888ed163835e3499f39c5 /benchmark | |
parent | 921c3c2097f170c881c2f3f264b89f792c204075 (diff) |
bench: buffer-base64-encode
Diffstat (limited to 'benchmark')
-rw-r--r-- | benchmark/buffers/buffer-base64-encode.js (renamed from benchmark/buffer-base64-encode.js) | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/benchmark/buffer-base64-encode.js b/benchmark/buffers/buffer-base64-encode.js index 7ead3a575dc..f2b8e9a4821 100644 --- a/benchmark/buffer-base64-encode.js +++ b/benchmark/buffers/buffer-base64-encode.js @@ -19,9 +19,18 @@ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. -var N = 64*1024*1024 -var b = Buffer(N); -var s = ''; -for (var i = 0; i < 256; ++i) s += String.fromCharCode(i); -for (var i = 0; i < N; i += 256) b.write(s, i, 256, 'ascii'); -for (var i = 0; i < 32; ++i) b.toString('base64'); +var common = require('../common.js'); + +var bench = common.createBenchmark(main, {}); + +function main(conf) { + var N = 64 * 1024 * 1024; + var b = Buffer(N); + var s = ''; + for (var i = 0; i < 256; ++i) s += String.fromCharCode(i); + + bench.start(); + for (var i = 0; i < N; i += 256) b.write(s, i, 256, 'ascii'); + for (var i = 0; i < 32; ++i) b.toString('base64'); + bench.end(64); +} |