lib/dist.js
function divideWork(script, numWorkers) {
  let newPhases = [];
  for (let i = 0; i < numWorkers; i++) {
    newPhases.push(L.cloneDeep(script.config.phases));
  }

  //
  // Adjust phase definitions:
  //
  L.each(script.config.phases, function(phase, phaseSpecIndex) {
    if (phase.arrivalRate && phase.rampTo) {
      let rates = distribute(phase.arrivalRate, numWorkers);
      let ramps = distribute(phase.rampTo, numWorkers);
      L.each(rates, function(Lr, i) {
        newPhases[i][phaseSpecIndex].arrivalRate = rates[i];
        newPhases[i][phaseSpecIndex].rampTo = ramps[i];
      });
      return;
    }

    if (phase.arrivalRate && !phase.rampTo) {
      let rates = distribute(phase.arrivalRate, numWorkers);
      L.each(rates, function(Lr, i) {
        newPhases[i][phaseSpecIndex].arrivalRate = rates[i];
      });
      return;
    }

    if (phase.arrivalCount) {
      let counts = distribute(phase.arrivalCount, numWorkers);
      L.each(counts, function(Lc, i) {
        newPhases[i][phaseSpecIndex].arrivalCount = counts[i];
      });
      return;
    }

    if (phase.pause) {
      // nothing to adjust here
      return;
    }

    console.log('Unknown phase spec definition, skipping.\n%j\n' +
                'This should not happen', phase);
  });

  //
  // Create new scripts:
  //
  let newScripts = L.map(L.range(0, numWorkers), function(i) {
    let newScript = L.cloneDeep(script);
    newScript.config.phases = newPhases[i];
    return newScript;
  });

  //
  // Adjust pool settings for HTTP if needed:
  //
  // FIXME: makes multicore code tightly coupled to the engines; replace with
  // something less coupled.
  if (!L.isUndefined(L.get(script, 'config.http.pool'))) {
    let pools = distribute(script.config.http.pool, numWorkers);
    L.each(newScripts, function(s, i) {
      s.config.http.pool = pools[i];
    });
  }

  return newScripts;
}
function divideWork(script, numWorkers) {
  let newPhases = [];
  for (let i = 0; i < numWorkers; i++) {
    newPhases.push(L.cloneDeep(script.config.phases));
  }

  //
  // Adjust phase definitions:
  //
  L.each(script.config.phases, function(phase, phaseSpecIndex) {
    if (phase.arrivalRate && phase.rampTo) {
      let rates = distribute(phase.arrivalRate, numWorkers);
      let ramps = distribute(phase.rampTo, numWorkers);
      L.each(rates, function(Lr, i) {
        newPhases[i][phaseSpecIndex].arrivalRate = rates[i];
        newPhases[i][phaseSpecIndex].rampTo = ramps[i];
      });
      return;
    }

    if (phase.arrivalRate && !phase.rampTo) {
      let rates = distribute(phase.arrivalRate, numWorkers);
      L.each(rates, function(Lr, i) {
        newPhases[i][phaseSpecIndex].arrivalRate = rates[i];
      });
      return;
    }

    if (phase.arrivalCount) {
      let counts = distribute(phase.arrivalCount, numWorkers);
      L.each(counts, function(Lc, i) {
        newPhases[i][phaseSpecIndex].arrivalCount = counts[i];
      });
      return;
    }

    if (phase.pause) {
      // nothing to adjust here
      return;
    }

    console.log('Unknown phase spec definition, skipping.\n%j\n' +
                'This should not happen', phase);
  });

  //
  // Create new scripts:
  //
  let newScripts = L.map(L.range(0, numWorkers), function(i) {
    let newScript = L.cloneDeep(script);
    newScript.config.phases = newPhases[i];
    return newScript;
  });

  //
  // Adjust pool settings for HTTP if needed:
  //
  // FIXME: makes multicore code tightly coupled to the engines; replace with
  // something less coupled.
  if (!L.isUndefined(L.get(script, 'config.http.pool'))) {
    let pools = distribute(script.config.http.pool, numWorkers);
    L.each(newScripts, function(s, i) {
      s.config.http.pool = pools[i];
    });
  }

  return newScripts;
}
function divideWork ( script , numWorkers ) { let newPhases = [ ] ; for ( let i = 0 ; i < numWorkers ; i ++ ) { newPhases . push ( L . cloneDeep ( script . config . phases ) ) ; } // // Adjust phase definitions: // L . each ( script . config . phases , function ( phase , phaseSpecIndex ) { if ( phase . arrivalRate && phase . rampTo ) { let rates = distribute ( phase . arrivalRate , numWorkers ) ; let ramps = distribute ( phase . rampTo , numWorkers ) ; L . each ( rates , function ( Lr , i ) { newPhases [ i ] [ phaseSpecIndex ] . arrivalRate = rates [ i ] ; newPhases [ i ] [ phaseSpecIndex ] . rampTo = ramps [ i ] ; } ) ; return ; } if ( phase . arrivalRate && ! phase . rampTo ) { let rates = distribute ( phase . arrivalRate , numWorkers ) ; L . each ( rates , function ( Lr , i ) { newPhases [ i ] [ phaseSpecIndex ] . arrivalRate = rates [ i ] ; } ) ; return ; } if ( phase . arrivalCount ) { let counts = distribute ( phase . arrivalCount , numWorkers ) ; L . each ( counts , function ( Lc , i ) { newPhases [ i ] [ phaseSpecIndex ] . arrivalCount = counts [ i ] ; } ) ; return ; } if ( phase . pause ) { // nothing to adjust here return ; } console . log ( 'Unknown phase spec definition, skipping.\n%j\n' + 'This should not happen' , phase ) ; } ) ; // // Create new scripts: // let newScripts = L . map ( L . range ( 0 , numWorkers ) , function ( i ) { let newScript = L . cloneDeep ( script ) ; newScript . config . phases = newPhases [ i ] ; return newScript ; } ) ; // // Adjust pool settings for HTTP if needed: // // FIXME: makes multicore code tightly coupled to the engines; replace with // something less coupled. if ( ! L . isUndefined ( L . get ( script , 'config.http.pool' ) ) ) { let pools = distribute ( script . config . http . pool , numWorkers ) ; L . each ( newScripts , function ( s , i ) { s . config . http . pool = pools [ i ] ; } ) ; } return newScripts ; }
Create a number of scripts for workers from the script given to use by user.
Create a number of scripts for workers from the script given to use by user .