11cb0ef41Sopenharmony_ci'use strict';
21cb0ef41Sopenharmony_ci
31cb0ef41Sopenharmony_ciconst common = require('../common');
41cb0ef41Sopenharmony_ciconst util = require('util');
51cb0ef41Sopenharmony_ci
61cb0ef41Sopenharmony_ciconst bench = common.createBenchmark(main, {
71cb0ef41Sopenharmony_ci  n: [5e2],
81cb0ef41Sopenharmony_ci  len: [1e2, 1e5],
91cb0ef41Sopenharmony_ci  type: [
101cb0ef41Sopenharmony_ci    'denseArray',
111cb0ef41Sopenharmony_ci    'sparseArray',
121cb0ef41Sopenharmony_ci    'mixedArray',
131cb0ef41Sopenharmony_ci    'denseArray_showHidden',
141cb0ef41Sopenharmony_ci  ],
151cb0ef41Sopenharmony_ci});
161cb0ef41Sopenharmony_ci
171cb0ef41Sopenharmony_cifunction main({ n, len, type }) {
181cb0ef41Sopenharmony_ci  let arr = Array(len);
191cb0ef41Sopenharmony_ci  let opts;
201cb0ef41Sopenharmony_ci
211cb0ef41Sopenharmony_ci  switch (type) {
221cb0ef41Sopenharmony_ci    case 'denseArray_showHidden':
231cb0ef41Sopenharmony_ci      opts = { showHidden: true };
241cb0ef41Sopenharmony_ci      arr = arr.fill('denseArray');
251cb0ef41Sopenharmony_ci      break;
261cb0ef41Sopenharmony_ci    case 'denseArray':
271cb0ef41Sopenharmony_ci      arr = arr.fill('denseArray');
281cb0ef41Sopenharmony_ci      break;
291cb0ef41Sopenharmony_ci    case 'sparseArray':
301cb0ef41Sopenharmony_ci      break;
311cb0ef41Sopenharmony_ci    case 'mixedArray':
321cb0ef41Sopenharmony_ci      for (let i = 0; i < n; i += 2)
331cb0ef41Sopenharmony_ci        arr[i] = i;
341cb0ef41Sopenharmony_ci      break;
351cb0ef41Sopenharmony_ci    default:
361cb0ef41Sopenharmony_ci      throw new Error(`Unsupported type ${type}`);
371cb0ef41Sopenharmony_ci  }
381cb0ef41Sopenharmony_ci  bench.start();
391cb0ef41Sopenharmony_ci  for (let i = 0; i < n; i++) {
401cb0ef41Sopenharmony_ci    util.inspect(arr, opts);
411cb0ef41Sopenharmony_ci  }
421cb0ef41Sopenharmony_ci  bench.end(n);
431cb0ef41Sopenharmony_ci}
44