From: Jesse Tane Date: Fri, 19 Dec 2014 20:40:25 +0000 (-0500) Subject: add benchmark for encoding to utf8 X-Git-Url: https://zoso.dev/?a=commitdiff_plain;h=15330d03aa981ad9e2e0c6a2e7ff9a1ef4f5eef4;p=buffer.git add benchmark for encoding to utf8 --- diff --git a/perf/writeUtf8.js b/perf/writeUtf8.js new file mode 100644 index 0000000..ba1c573 --- /dev/null +++ b/perf/writeUtf8.js @@ -0,0 +1,26 @@ +var BrowserBuffer = require('../').Buffer // (this module) +var util = require('./util') +var suite = util.suite() + +var LENGTH = 9 +var singleByte = 'abcdefghi' +var multiByte = '\u0610' + '\u6100' + '\uD944\uDC00' + +var browserBuffer = new BrowserBuffer(LENGTH) +var nodeBuffer = new Buffer(LENGTH) + +suite + .add('BrowserBuffer#singleByte', function () { + browserBuffer.write(singleByte) + }) + .add('BrowserBuffer#multiByte', function () { + browserBuffer.write(multiByte) + }) + +if (!process.browser) suite + .add('NodeBuffer#singleByte', function () { + nodeBuffer.write(singleByte) + }) + .add('NodeBuffer#multiByte', function () { + nodeBuffer.write(multiByte) + })