diff options
Diffstat (limited to 'benchmark/util/text-decoder.js')
-rw-r--r-- | benchmark/util/text-decoder.js | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/benchmark/util/text-decoder.js b/benchmark/util/text-decoder.js new file mode 100644 index 00000000000..ad845f7c92d --- /dev/null +++ b/benchmark/util/text-decoder.js @@ -0,0 +1,19 @@ +'use strict'; + +const common = require('../common.js'); + +const bench = common.createBenchmark(main, { + encoding: ['utf-8', 'latin1', 'iso-8859-3'], + ignoreBOM: [0, 1], + len: [256, 1024 * 16, 1024 * 512], + n: [1e6] +}); + +function main({ encoding, len, n, ignoreBOM }) { + const buf = Buffer.allocUnsafe(len); + const decoder = new TextDecoder(encoding, { ignoreBOM }); + + bench.start(); + decoder.decode(buf); + bench.end(n); +} |