From 56223c5ce6276bcee8dac2402dce7cd3b5ef4ea2 Mon Sep 17 00:00:00 2001 From: Jesse Tane Date: Mon, 10 Aug 2015 22:55:17 -0400 Subject: [PATCH] add readUtf8 benchmark --- perf/readUtf8.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 perf/readUtf8.js diff --git a/perf/readUtf8.js b/perf/readUtf8.js new file mode 100644 index 0000000..a0109ff --- /dev/null +++ b/perf/readUtf8.js @@ -0,0 +1,19 @@ +var BrowserBuffer = require('../').Buffer // (this module) +var util = require('./util') +var suite = util.suite() + +// 256 random bytes +var array = [ 152, 130, 206, 23, 243, 238, 197, 44, 27, 86, 208, 36, 163, 184, 164, 21, 94, 242, 178, 46, 25, 26, 253, 178, 72, 147, 207, 112, 236, 68, 179, 190, 29, 83, 239, 147, 125, 55, 143, 19, 157, 68, 157, 58, 212, 224, 150, 39, 128, 24, 94, 225, 120, 121, 75, 192, 112, 19, 184, 142, 203, 36, 43, 85, 26, 147, 227, 139, 242, 186, 57, 78, 11, 102, 136, 117, 180, 210, 241, 92, 3, 215, 54, 167, 249, 1, 44, 225, 146, 86, 2, 42, 68, 21, 47, 238, 204, 153, 216, 252, 183, 66, 222, 255, 15, 202, 16, 51, 134, 1, 17, 19, 209, 76, 238, 38, 76, 19, 7, 103, 249, 5, 107, 137, 64, 62, 170, 57, 16, 85, 179, 193, 97, 86, 166, 196, 36, 148, 138, 193, 210, 69, 187, 38, 242, 97, 195, 219, 252, 244, 38, 1, 197, 18, 31, 246, 53, 47, 134, 52, 105, 72, 43, 239, 128, 203, 73, 93, 199, 75, 222, 220, 166, 34, 63, 236, 11, 212, 76, 243, 171, 110, 78, 39, 205, 204, 6, 177, 233, 212, 243, 0, 33, 41, 122, 118, 92, 252, 0, 157, 108, 120, 70, 137, 100, 223, 243, 171, 232, 66, 126, 111, 142, 33, 3, 39, 117, 27, 107, 54, 1, 217, 227, 132, 13, 166, 3, 73, 53, 127, 225, 236, 134, 219, 98, 214, 125, 148, 24, 64, 142, 111, 231, 194, 42, 150, 185, 10, 182, 163, 244, 19, 4, 59, 135, 16 ] + +var browserBuffer = new BrowserBuffer(array) +var nodeBuffer = new Buffer(array) + +suite + .add('BrowserBuffer#readUtf8', function () { + browserBuffer.toString() + }) + +if (!process.browser) suite + .add('NodeBuffer#readUtf8', function () { + nodeBuffer.toString() + }) -- 2.34.1