11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ciconst common = require('../common.js'); 31cb0ef41Sopenharmony_ciconst domain = require('domain'); 41cb0ef41Sopenharmony_ci 51cb0ef41Sopenharmony_ciconst bench = common.createBenchmark(main, { 61cb0ef41Sopenharmony_ci args: [0, 1, 2, 3], 71cb0ef41Sopenharmony_ci n: [10], 81cb0ef41Sopenharmony_ci}); 91cb0ef41Sopenharmony_ci 101cb0ef41Sopenharmony_ciconst bdomain = domain.create(); 111cb0ef41Sopenharmony_ciconst gargs = [1, 2, 3]; 121cb0ef41Sopenharmony_ci 131cb0ef41Sopenharmony_cifunction main({ n, args }) { 141cb0ef41Sopenharmony_ci const myArguments = gargs.slice(0, args); 151cb0ef41Sopenharmony_ci bench.start(); 161cb0ef41Sopenharmony_ci 171cb0ef41Sopenharmony_ci bdomain.enter(); 181cb0ef41Sopenharmony_ci for (let i = 0; i < n; i++) { 191cb0ef41Sopenharmony_ci if (myArguments.length >= 2) { 201cb0ef41Sopenharmony_ci const args = Array.prototype.slice.call(myArguments, 1); 211cb0ef41Sopenharmony_ci fn.apply(this, args); 221cb0ef41Sopenharmony_ci } else { 231cb0ef41Sopenharmony_ci fn.call(this); 241cb0ef41Sopenharmony_ci } 251cb0ef41Sopenharmony_ci } 261cb0ef41Sopenharmony_ci bdomain.exit(); 271cb0ef41Sopenharmony_ci 281cb0ef41Sopenharmony_ci bench.end(n); 291cb0ef41Sopenharmony_ci} 301cb0ef41Sopenharmony_ci 311cb0ef41Sopenharmony_cifunction fn(a = 1, b = 2, c = 3) { 321cb0ef41Sopenharmony_ci return a + b + c; 331cb0ef41Sopenharmony_ci} 34