11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ciconst common = require('../common.js'); 31cb0ef41Sopenharmony_ci 41cb0ef41Sopenharmony_ciconst types = [ 51cb0ef41Sopenharmony_ci 'BigUInt64LE', 61cb0ef41Sopenharmony_ci 'BigUInt64BE', 71cb0ef41Sopenharmony_ci 'BigInt64LE', 81cb0ef41Sopenharmony_ci 'BigInt64BE', 91cb0ef41Sopenharmony_ci 'UInt8', 101cb0ef41Sopenharmony_ci 'UInt16LE', 111cb0ef41Sopenharmony_ci 'UInt16BE', 121cb0ef41Sopenharmony_ci 'UInt32LE', 131cb0ef41Sopenharmony_ci 'UInt32BE', 141cb0ef41Sopenharmony_ci 'Int8', 151cb0ef41Sopenharmony_ci 'Int16LE', 161cb0ef41Sopenharmony_ci 'Int16BE', 171cb0ef41Sopenharmony_ci 'Int32LE', 181cb0ef41Sopenharmony_ci 'Int32BE', 191cb0ef41Sopenharmony_ci]; 201cb0ef41Sopenharmony_ci 211cb0ef41Sopenharmony_ciconst bench = common.createBenchmark(main, { 221cb0ef41Sopenharmony_ci buffer: ['fast'], 231cb0ef41Sopenharmony_ci type: types, 241cb0ef41Sopenharmony_ci n: [1e6], 251cb0ef41Sopenharmony_ci}); 261cb0ef41Sopenharmony_ci 271cb0ef41Sopenharmony_cifunction main({ n, buf, type }) { 281cb0ef41Sopenharmony_ci const buff = buf === 'fast' ? 291cb0ef41Sopenharmony_ci Buffer.alloc(8) : 301cb0ef41Sopenharmony_ci require('buffer').SlowBuffer(8); 311cb0ef41Sopenharmony_ci const fn = `read${type}`; 321cb0ef41Sopenharmony_ci 331cb0ef41Sopenharmony_ci buff.writeDoubleLE(0, 0); 341cb0ef41Sopenharmony_ci bench.start(); 351cb0ef41Sopenharmony_ci 361cb0ef41Sopenharmony_ci for (let i = 0; i !== n; i++) { 371cb0ef41Sopenharmony_ci buff[fn](0); 381cb0ef41Sopenharmony_ci } 391cb0ef41Sopenharmony_ci bench.end(n); 401cb0ef41Sopenharmony_ci} 41