]> zoso.dev Git - buffer.git/commitdiff
add benchmark for encoding to utf8
authorJesse Tane <jesse.tane@gmail.com>
Fri, 19 Dec 2014 20:40:25 +0000 (15:40 -0500)
committerJesse Tane <jesse.tane@gmail.com>
Mon, 22 Dec 2014 22:44:16 +0000 (17:44 -0500)
perf/writeUtf8.js [new file with mode: 0644]

diff --git a/perf/writeUtf8.js b/perf/writeUtf8.js
new file mode 100644 (file)
index 0000000..ba1c573
--- /dev/null
@@ -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)
+  })