core/lib/stats2.js
function combine(statsObjects) {
  let result = create();
  L.each(statsObjects, function(stats) {
    L.each(stats._latencies, function(latency) {
      result._latencies.push(latency);
    });
    result._generatedScenarios += stats._generatedScenarios;
    L.each(stats._scenarioCounter, function(count, name) {
      if(result._scenarioCounter[name]) {
        result._scenarioCounter[name] += count;
      } else {
        result._scenarioCounter[name] = count;
      }
    });
    result._completedScenarios += stats._completedScenarios;
    result._scenariosAvoided += stats._scenariosAvoided;
    L.each(stats._codes, function(count, code) {
      if(result._codes[code]) {
        result._codes[code] += count;
      } else {
        result._codes[code] = count;
      }
    });
    L.each(stats._errors, function(count, error) {
      if(result._errors[error]) {
        result._errors[error] += count;
      } else {
        result._errors[error] = count;
      }
    });
    L.each(stats._requestTimestamps, function(timestamp) {
      result._requestTimestamps.push(timestamp);
    });
    result._completedRequests += stats._completedRequests;
    L.each(stats._scenarioLatencies, function(latency) {
      result._scenarioLatencies.push(latency);
    });
    result._matches += stats._matches;

    L.each(stats._counters, function(value, name) {
      if (!result._counters[name]) {
        result._counters[name] = 0;
      }
      result._counters[name] += value;
    });
    L.each(stats._customStats, function(values, name) {
      if (!result._customStats[name]) {
        result._customStats[name] = [];
      }

      L.each(values, function(v) {
        result._customStats[name].push(v);
      });
    });

    result._concurrency += stats._concurrency || 0;
    result._pendingRequests += stats._pendingRequests;
  });

  return result;
}
function combine(statsObjects) {
  let result = create();
  L.each(statsObjects, function(stats) {
    L.each(stats._latencies, function(latency) {
      result._latencies.push(latency);
    });
    result._generatedScenarios += stats._generatedScenarios;
    L.each(stats._scenarioCounter, function(count, name) {
      if(result._scenarioCounter[name]) {
        result._scenarioCounter[name] += count;
      } else {
        result._scenarioCounter[name] = count;
      }
    });
    result._completedScenarios += stats._completedScenarios;
    result._scenariosAvoided += stats._scenariosAvoided;
    L.each(stats._codes, function(count, code) {
      if(result._codes[code]) {
        result._codes[code] += count;
      } else {
        result._codes[code] = count;
      }
    });
    L.each(stats._errors, function(count, error) {
      if(result._errors[error]) {
        result._errors[error] += count;
      } else {
        result._errors[error] = count;
      }
    });
    L.each(stats._requestTimestamps, function(timestamp) {
      result._requestTimestamps.push(timestamp);
    });
    result._completedRequests += stats._completedRequests;
    L.each(stats._scenarioLatencies, function(latency) {
      result._scenarioLatencies.push(latency);
    });
    result._matches += stats._matches;

    L.each(stats._counters, function(value, name) {
      if (!result._counters[name]) {
        result._counters[name] = 0;
      }
      result._counters[name] += value;
    });
    L.each(stats._customStats, function(values, name) {
      if (!result._customStats[name]) {
        result._customStats[name] = [];
      }

      L.each(values, function(v) {
        result._customStats[name].push(v);
      });
    });

    result._concurrency += stats._concurrency || 0;
    result._pendingRequests += stats._pendingRequests;
  });

  return result;
}
function combine ( statsObjects ) { let result = create ( ) ; L . each ( statsObjects , function ( stats ) { L . each ( stats . _latencies , function ( latency ) { result . _latencies . push ( latency ) ; } ) ; result . _generatedScenarios += stats . _generatedScenarios ; L . each ( stats . _scenarioCounter , function ( count , name ) { if ( result . _scenarioCounter [ name ] ) { result . _scenarioCounter [ name ] += count ; } else { result . _scenarioCounter [ name ] = count ; } } ) ; result . _completedScenarios += stats . _completedScenarios ; result . _scenariosAvoided += stats . _scenariosAvoided ; L . each ( stats . _codes , function ( count , code ) { if ( result . _codes [ code ] ) { result . _codes [ code ] += count ; } else { result . _codes [ code ] = count ; } } ) ; L . each ( stats . _errors , function ( count , error ) { if ( result . _errors [ error ] ) { result . _errors [ error ] += count ; } else { result . _errors [ error ] = count ; } } ) ; L . each ( stats . _requestTimestamps , function ( timestamp ) { result . _requestTimestamps . push ( timestamp ) ; } ) ; result . _completedRequests += stats . _completedRequests ; L . each ( stats . _scenarioLatencies , function ( latency ) { result . _scenarioLatencies . push ( latency ) ; } ) ; result . _matches += stats . _matches ; L . each ( stats . _counters , function ( value , name ) { if ( ! result . _counters [ name ] ) { result . _counters [ name ] = 0 ; } result . _counters [ name ] += value ; } ) ; L . each ( stats . _customStats , function ( values , name ) { if ( ! result . _customStats [ name ] ) { result . _customStats [ name ] = [ ] ; } L . each ( values , function ( v ) { result . _customStats [ name ] . push ( v ) ; } ) ; } ) ; result . _concurrency += stats . _concurrency || 0 ; result . _pendingRequests += stats . _pendingRequests ; } ) ; return result ; }
Combine several stats objects from different workers into one
Combine several stats objects from different workers into one