11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ciconst common = require('../common.js'); 31cb0ef41Sopenharmony_ci 41cb0ef41Sopenharmony_ciconst bench = common.createBenchmark(main, { 51cb0ef41Sopenharmony_ci type: [ 61cb0ef41Sopenharmony_ci 'fill(0)', 71cb0ef41Sopenharmony_ci 'fill("")', 81cb0ef41Sopenharmony_ci 'fill(100)', 91cb0ef41Sopenharmony_ci 'fill(400)', 101cb0ef41Sopenharmony_ci 'fill("t")', 111cb0ef41Sopenharmony_ci 'fill("test")', 121cb0ef41Sopenharmony_ci 'fill("t", "utf8")', 131cb0ef41Sopenharmony_ci 'fill("t", 0, "utf8")', 141cb0ef41Sopenharmony_ci 'fill("t", 0)', 151cb0ef41Sopenharmony_ci 'fill(Buffer.alloc(1), 0)', 161cb0ef41Sopenharmony_ci ], 171cb0ef41Sopenharmony_ci size: [2 ** 13, 2 ** 16], 181cb0ef41Sopenharmony_ci n: [2e4], 191cb0ef41Sopenharmony_ci}); 201cb0ef41Sopenharmony_ci 211cb0ef41Sopenharmony_cifunction main({ n, type, size }) { 221cb0ef41Sopenharmony_ci const buffer = Buffer.allocUnsafe(size); 231cb0ef41Sopenharmony_ci const testFunction = new Function('b', ` 241cb0ef41Sopenharmony_ci for (var i = 0; i < ${n}; i++) { 251cb0ef41Sopenharmony_ci b.${type}; 261cb0ef41Sopenharmony_ci } 271cb0ef41Sopenharmony_ci `); 281cb0ef41Sopenharmony_ci bench.start(); 291cb0ef41Sopenharmony_ci testFunction(buffer); 301cb0ef41Sopenharmony_ci bench.end(n); 311cb0ef41Sopenharmony_ci} 32