11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ciconst common = require('../common'); 31cb0ef41Sopenharmony_ci 41cb0ef41Sopenharmony_ciconst bench = common.createBenchmark(main, { 51cb0ef41Sopenharmony_ci len: [2, 16, 256], // x16 61cb0ef41Sopenharmony_ci n: [4e6], 71cb0ef41Sopenharmony_ci}); 81cb0ef41Sopenharmony_ci 91cb0ef41Sopenharmony_cifunction main({ n, len }) { 101cb0ef41Sopenharmony_ci const data = Buffer.alloc(len * 16, 'a'); 111cb0ef41Sopenharmony_ci const expected = Buffer.byteLength(data, 'buffer'); 121cb0ef41Sopenharmony_ci let changed = false; 131cb0ef41Sopenharmony_ci bench.start(); 141cb0ef41Sopenharmony_ci for (let i = 0; i < n; i++) { 151cb0ef41Sopenharmony_ci const actual = Buffer.byteLength(data, 'buffer'); 161cb0ef41Sopenharmony_ci if (expected !== actual) { changed = true; } 171cb0ef41Sopenharmony_ci } 181cb0ef41Sopenharmony_ci bench.end(n); 191cb0ef41Sopenharmony_ci if (changed) { 201cb0ef41Sopenharmony_ci throw new Error('Result changed during iteration'); 211cb0ef41Sopenharmony_ci } 221cb0ef41Sopenharmony_ci} 23