2016-05-15 14:53:08 -04:00
|
|
|
'use strict';
|
|
|
|
const common = require('../common.js');
|
|
|
|
const StringDecoder = require('string_decoder').StringDecoder;
|
|
|
|
|
|
|
|
const bench = common.createBenchmark(main, {
|
|
|
|
encoding: [
|
2019-02-04 22:06:08 -08:00
|
|
|
'ascii', 'utf8', 'utf-8', 'base64', 'ucs2', 'UTF-8', 'AscII', 'UTF-16LE',
|
2016-05-15 14:53:08 -04:00
|
|
|
],
|
|
|
|
n: [25e6]
|
|
|
|
});
|
|
|
|
|
2017-12-30 03:57:10 +01:00
|
|
|
function main({ encoding, n }) {
|
2016-05-15 14:53:08 -04:00
|
|
|
bench.start();
|
2019-07-31 08:26:38 -05:00
|
|
|
for (let i = 0; i < n; ++i) {
|
2016-05-15 14:53:08 -04:00
|
|
|
const sd = new StringDecoder(encoding);
|
|
|
|
!!sd.encoding;
|
|
|
|
}
|
|
|
|
bench.end(n);
|
|
|
|
}
|