'use strict'var nul = process.platform === 'win32' ? '\\\\.\\NUL' : '/dev/null'var bench = require('fastbench')var stream = require('fs').createWriteStream(nul)var flatstr = require('./')var largeStr = JSON.stringify(require('./package.json'))largeStr += largeStrlargeStr += largeStrvar run = bench([function unflattenedManySmallConcats (cb) {stream.write(makeStr('a', 200))setImmediate(cb)},function flattenedManySmallConcats (cb) {stream.write(flatstr(makeStr('a', 200)))setImmediate(cb)},function unflattenedSeveralLargeConcats (cb) {stream.write(makeStr(largeStr, 10))setImmediate(cb)},function flattenedSeveralLargeConcats (cb) {stream.write(flatstr(makeStr(largeStr, 10)))setImmediate(cb)},function unflattenedExponentialSmallConcats (cb) {stream.write(makeExpoStr('a', 12))setImmediate(cb)},function flattenedExponentialSmallConcats (cb) {stream.write(flatstr(makeExpoStr('a', 12)))setImmediate(cb)},function unflattenedExponentialLargeConcats (cb) {stream.write(makeExpoStr(largeStr, 7))setImmediate(cb)},function flattenedExponentialLargeConcats (cb) {stream.write(flatstr(makeExpoStr(largeStr, 7)))setImmediate(cb)}], 10000)run(run)function makeStr (str, concats) {var s = ''while (concats--) {s += str}return s}function makeExpoStr (str, concats) {var s = strwhile (concats--) {s += s}return s}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。