11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ciconst common = require('../common.js'); 31cb0ef41Sopenharmony_ci 41cb0ef41Sopenharmony_ciconst bench = common.createBenchmark(main, { 51cb0ef41Sopenharmony_ci n: [1e6], 61cb0ef41Sopenharmony_ci nListener: [5, 10], 71cb0ef41Sopenharmony_ci}); 81cb0ef41Sopenharmony_ci 91cb0ef41Sopenharmony_cifunction main({ n, nListener }) { 101cb0ef41Sopenharmony_ci const target = new EventTarget(); 111cb0ef41Sopenharmony_ci const listeners = []; 121cb0ef41Sopenharmony_ci for (let k = 0; k < nListener; k += 1) 131cb0ef41Sopenharmony_ci listeners.push(() => {}); 141cb0ef41Sopenharmony_ci 151cb0ef41Sopenharmony_ci bench.start(); 161cb0ef41Sopenharmony_ci for (let i = 0; i < n; i += 1) { 171cb0ef41Sopenharmony_ci const dummy = (i % 2 === 0) ? 'dummy0' : 'dummy1'; 181cb0ef41Sopenharmony_ci for (let k = listeners.length; --k >= 0;) { 191cb0ef41Sopenharmony_ci target.addEventListener(dummy, listeners[k]); 201cb0ef41Sopenharmony_ci } 211cb0ef41Sopenharmony_ci for (let k = listeners.length; --k >= 0;) { 221cb0ef41Sopenharmony_ci target.removeEventListener(dummy, listeners[k]); 231cb0ef41Sopenharmony_ci } 241cb0ef41Sopenharmony_ci } 251cb0ef41Sopenharmony_ci bench.end(n); 261cb0ef41Sopenharmony_ci} 27