11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ciconst common = require('../common.js'); 31cb0ef41Sopenharmony_ci 41cb0ef41Sopenharmony_ciconst bench = common.createBenchmark(main, { 51cb0ef41Sopenharmony_ci size: [16, 512, 4096, 16386], 61cb0ef41Sopenharmony_ci args: [1, 2, 5], 71cb0ef41Sopenharmony_ci n: [1e6], 81cb0ef41Sopenharmony_ci}); 91cb0ef41Sopenharmony_ci 101cb0ef41Sopenharmony_cifunction main({ n, size, args }) { 111cb0ef41Sopenharmony_ci const b0 = Buffer.alloc(size, 'a'); 121cb0ef41Sopenharmony_ci const b1 = Buffer.alloc(size, 'a'); 131cb0ef41Sopenharmony_ci const b0Len = b0.length; 141cb0ef41Sopenharmony_ci const b1Len = b1.length; 151cb0ef41Sopenharmony_ci 161cb0ef41Sopenharmony_ci b1[size - 1] = 'b'.charCodeAt(0); 171cb0ef41Sopenharmony_ci 181cb0ef41Sopenharmony_ci switch (args) { 191cb0ef41Sopenharmony_ci case 2: 201cb0ef41Sopenharmony_ci b0.compare(b1, 0); 211cb0ef41Sopenharmony_ci bench.start(); 221cb0ef41Sopenharmony_ci for (let i = 0; i < n; i++) { 231cb0ef41Sopenharmony_ci b0.compare(b1, 0); 241cb0ef41Sopenharmony_ci } 251cb0ef41Sopenharmony_ci bench.end(n); 261cb0ef41Sopenharmony_ci break; 271cb0ef41Sopenharmony_ci case 3: 281cb0ef41Sopenharmony_ci b0.compare(b1, 0, b1Len); 291cb0ef41Sopenharmony_ci bench.start(); 301cb0ef41Sopenharmony_ci for (let i = 0; i < n; i++) { 311cb0ef41Sopenharmony_ci b0.compare(b1, 0, b1Len); 321cb0ef41Sopenharmony_ci } 331cb0ef41Sopenharmony_ci bench.end(n); 341cb0ef41Sopenharmony_ci break; 351cb0ef41Sopenharmony_ci case 4: 361cb0ef41Sopenharmony_ci b0.compare(b1, 0, b1Len, 0); 371cb0ef41Sopenharmony_ci bench.start(); 381cb0ef41Sopenharmony_ci for (let i = 0; i < n; i++) { 391cb0ef41Sopenharmony_ci b0.compare(b1, 0, b1Len, 0); 401cb0ef41Sopenharmony_ci } 411cb0ef41Sopenharmony_ci bench.end(n); 421cb0ef41Sopenharmony_ci break; 431cb0ef41Sopenharmony_ci case 5: 441cb0ef41Sopenharmony_ci b0.compare(b1, 0, b1Len, 0, b0Len); 451cb0ef41Sopenharmony_ci bench.start(); 461cb0ef41Sopenharmony_ci for (let i = 0; i < n; i++) { 471cb0ef41Sopenharmony_ci b0.compare(b1, 0, b1Len, 0, b0Len); 481cb0ef41Sopenharmony_ci } 491cb0ef41Sopenharmony_ci bench.end(n); 501cb0ef41Sopenharmony_ci break; 511cb0ef41Sopenharmony_ci default: 521cb0ef41Sopenharmony_ci b0.compare(b1); 531cb0ef41Sopenharmony_ci bench.start(); 541cb0ef41Sopenharmony_ci for (let i = 0; i < n; i++) { 551cb0ef41Sopenharmony_ci b0.compare(b1); 561cb0ef41Sopenharmony_ci } 571cb0ef41Sopenharmony_ci bench.end(n); 581cb0ef41Sopenharmony_ci } 591cb0ef41Sopenharmony_ci} 60