xref: /third_party/node/test/fixtures/workload/bounded.js
  • Home
  • History
  • Annotate Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
  • only in /third_party/node/test/fixtures/workload/
11cb0ef41Sopenharmony_ci'use strict';
21cb0ef41Sopenharmony_ci
31cb0ef41Sopenharmony_ciconst total = parseInt(process.env.TEST_ALLOCATION) || 5000;
41cb0ef41Sopenharmony_ciconst chunk = parseInt(process.env.TEST_CHUNK) || 1000;
51cb0ef41Sopenharmony_ciconst cleanInterval = parseInt(process.env.TEST_CLEAN_INTERVAL) || 100;
61cb0ef41Sopenharmony_cilet count = 0;
71cb0ef41Sopenharmony_cilet arr = [];
81cb0ef41Sopenharmony_cifunction runAllocation() {
91cb0ef41Sopenharmony_ci  count++;
101cb0ef41Sopenharmony_ci  if (count < total) {
111cb0ef41Sopenharmony_ci    if (count % cleanInterval === 0) {
121cb0ef41Sopenharmony_ci      arr.splice(0, arr.length);
131cb0ef41Sopenharmony_ci      setImmediate(runAllocation);
141cb0ef41Sopenharmony_ci    } else {
151cb0ef41Sopenharmony_ci      const str = JSON.stringify(process.config).slice(0, chunk);
161cb0ef41Sopenharmony_ci      arr.push(str);
171cb0ef41Sopenharmony_ci      setImmediate(runAllocation);
181cb0ef41Sopenharmony_ci    }
191cb0ef41Sopenharmony_ci  }
201cb0ef41Sopenharmony_ci}
211cb0ef41Sopenharmony_ci
221cb0ef41Sopenharmony_cisetImmediate(runAllocation);
23

Indexes created Thu Nov 07 10:32:03 CST 2024