merge the array of reports together and rerun through the code to compute aggregates
188487
function mergeResults(jsRes, coffeeRes) {
    if (!coffeeRes) {
        return jsRes;
    }

    jsRes.reports = jsRes.reports.concat(coffeeRes.reports);

    return escomplex.processResults(jsRes, cli.nocoresize || false);
}
857917
public function merge()
    {
        // TODO: verify analysis phase run
        foreach ($this->dataFiles as $replicate => $fractions) {
            $firstFile = current($fractions);
            // Write header
            $this->writeHeader($firstFile['path'], $this->spectrumCount[$replicate], $this->outputFiles[$replicate]);

            // Resets vars
            $this->spectrumIdRef = array();
            $this->timeOffset = 0;
            $this->indexOffset = 0;
            $this->idOffset = 0;

            foreach ($fractions as $fractionIndex => $file) {
                $this->writeSpectrum($file['path'], $this->outputFiles[$replicate],
                    $this->fractionOffsets[$fractionIndex]);
            }

            $this->writeFooter($firstFile['path'], $this->outputFiles[$replicate]);
        }
    }
243203
public void combine(LongSummaryStatistics other) {
        count += other.count;
        sum += other.sum;
        min = Math.min(min, other.min);
        max = Math.max(max, other.max);
    }
746215
function merge() {
  var destination = {};
  var sources = [].slice.call(arguments, 0);
  sources.forEach(function(source) {
    var prop;
    for (prop in source) {
      if (prop in destination && Array.isArray(destination[prop])) {
        // Overwrite Arrays
        destination[prop] = source[prop];
      } else if (prop in destination && typeof destination[prop] === "object") {
        // Merge Objects
        destination[prop] = merge(destination[prop], source[prop]);
      } else {
        // Set new values
        destination[prop] = source[prop];
      }
    }
  });
  return destination;
}
881501
public void combine(WSStatistic otherStat) {
        if (!validate(otherStat))
            return;

        CountStatisticImpl other = (CountStatisticImpl) otherStat;
        count += other.count;

        // Compare lastSampleTime
        if (other.lastSampleTime > lastSampleTime)
            lastSampleTime = other.lastSampleTime;
    }
155896
function merge() {
	return Array.from(arguments)
		.reduce((result, current) => {
			Array.from(current)
				.forEach((value, index) => {
					result[index] = result[index] && typeof result[index] !== 'boolean' ? result[index] : value;
				});

			return result;
		}, []);
}
853628
function merge(arrays, comp) {
		var mid,
			a1, i1,
			a2, i2,
			result;

		if (arrays.length === 1) {
			return arrays[0];
		} else if (arrays.length === 2) {
			// merge two arrays
			a1 = arrays[0];
			a2 = arrays[1];
			i1 = i2 = 0;
			result = [];
			while(i1 < a1.length && i2 < a2.length) {
				if (comp(a2[i2], a1[i1]) > 0) {
					result.push(a1[i1]);
					i1++;
				} else {
					result.push(a2[i2]);
					i2++;
				}
			}
			while(i1 < a1.length) {
				result.push(a1[i1]);
				i1++;
			}
			while(i2 < a2.length) {
				result.push(a2[i2]);
				i2++;
			}
			return result;
		} else {
			mid = Math.floor(arrays.length / 2);
			return merge([
				merge(arrays.slice(0, mid), comp),
				merge(arrays.slice(mid), comp)
			], comp);
		}

	}
285845
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;
}
1204229
function processArray (arr, reqStack) {
  const accum = []
  arr.forEach(function (el) {
    accum.push(schemaForm(el, reqStack))
  })
  return accum
}
749542
def aggregate_in(self, On=None, AggFuncDict=None, AggFunc=None,
                 AggList=None, interspersed=True):
        
        data = spreadsheet.aggregate_in(Data=self, On=On, 
               AggFuncDict=AggFuncDict, AggFunc=AggFunc, 
               AggList = AggList, interspersed=interspersed)
        data = data.view(tabarray)
        data.view = self.coloring
        return data
237445
def merge_values(values1,values2):
    '''
    
    '''
    array1 = values_to_array(values1)
    array2 = values_to_array(values2)

    if array1.size == 0:
        return array2
    if array2.size == 0:
        return array1

    merged_array = []
    for row_array1 in array1:
        for row_array2 in array2:
            merged_row = np.hstack((row_array1,row_array2))
            merged_array.append(merged_row)
    return np.atleast_2d(merged_array)
1096164
def merge(*maps):
    """"""
    copies = map(deepcopy, maps)
    return reduce(lambda acc, val: acc.update(val) or acc, copies)
432173
def _aggregate(self):
        """"""
        # pylint: disable=W0212
        nonremote = [t for t in self._tasks if not isinstance(t, RemoteTask)]
        remote = [t for t in self._tasks if isinstance(t, RemoteTask)]

        host_dict = defaultdict(list)
        for task in remote:
            host_dict[task.host].append(task)

        aggregated = []
        for task_group in host_dict.values():
            # Build up combined command
            combined_cmd = []
            for task in task_group:
                if combined_cmd:
                    combined_cmd.append('&')
                combined_cmd.append(' '.join(task._remote_command))

            # Now, generated aggregate task
            t0 = task_group[0] # pylint: disable=C0103
            task = RemoteTask(
                t0.host, combined_cmd, t0._quiet, t0._return_output,
                t0._kill_remote, t0._identity_file)

            aggregated.append(task)

        self._tasks = nonremote + aggregated
1299651
def _aggregate(self, tests_results):
        
        summary = {
            "success": True,
            "stat": {
                "testcases": {
                    "total": len(tests_results),
                    "success": 0,
                    "fail": 0
                },
                "teststeps": {}
            },
            "time": {},
            "platform": report.get_platform(),
            "details": []
        }

        for tests_result in tests_results:
            testcase, result = tests_result
            testcase_summary = report.get_summary(result)

            if testcase_summary["success"]:
                summary["stat"]["testcases"]["success"] += 1
            else:
                summary["stat"]["testcases"]["fail"] += 1

            summary["success"] &= testcase_summary["success"]
            testcase_summary["name"] = testcase.config.get("name")
            testcase_summary["in_out"] = utils.get_testcase_io(testcase)

            report.aggregate_stat(summary["stat"]["teststeps"], testcase_summary["stat"])
            report.aggregate_stat(summary["time"], testcase_summary["time"])

            summary["details"].append(testcase_summary)

        return summary
328083
def refresh(self, datasource_names, merge_flag, refreshAll):
        
        session = db.session
        ds_list = (
            session.query(DruidDatasource)
            .filter(DruidDatasource.cluster_name == self.cluster_name)
            .filter(DruidDatasource.datasource_name.in_(datasource_names))
        )
        ds_map = {ds.name: ds for ds in ds_list}
        for ds_name in datasource_names:
            datasource = ds_map.get(ds_name, None)
            if not datasource:
                datasource = DruidDatasource(datasource_name=ds_name)
                with session.no_autoflush:
                    session.add(datasource)
                flasher(
                    _('Adding new datasource [{}]').format(ds_name), 'success')
                ds_map[ds_name] = datasource
            elif refreshAll:
                flasher(
                    _('Refreshing datasource [{}]').format(ds_name), 'info')
            else:
                del ds_map[ds_name]
                continue
            datasource.cluster = self
            datasource.merge_flag = merge_flag
        session.flush()

        # Prepare multithreaded executation
        pool = ThreadPool()
        ds_refresh = list(ds_map.values())
        metadata = pool.map(_fetch_metadata_for, ds_refresh)
        pool.close()
        pool.join()

        for i in range(0, len(ds_refresh)):
            datasource = ds_refresh[i]
            cols = metadata[i]
            if cols:
                col_objs_list = (
                    session.query(DruidColumn)
                    .filter(DruidColumn.datasource_id == datasource.id)
                    .filter(DruidColumn.column_name.in_(cols.keys()))
                )
                col_objs = {col.column_name: col for col in col_objs_list}
                for col in cols:
                    if col == '__time':  # skip the time column
                        continue
                    col_obj = col_objs.get(col)
                    if not col_obj:
                        col_obj = DruidColumn(
                            datasource_id=datasource.id,
                            column_name=col)
                        with session.no_autoflush:
                            session.add(col_obj)
                    col_obj.type = cols[col]['type']
                    col_obj.datasource = datasource
                    if col_obj.type == 'STRING':
                        col_obj.groupby = True
                        col_obj.filterable = True
                datasource.refresh_metrics()
        session.commit()
367244
function getDeeplyMergedValues(value1, value2) {
  if (isArray(value2)) {
    return !isArray(value1) ? value2 : mergeDeepArrays(value1, value2); // eslint-disable-line no-use-before-define
  }

  if (isObject(value2)) {
    return !isObject(value1) ? value2 : mergeDeepObjects(value1, value2); //eslint-disable-line no-use-before-define
  }

  return value2;
}
604775
def results_aggregator(results):
    '''
    
    '''

    def _flatten_unique(list_of_lists):
        l_flat = sum(list_of_lists, [])
        l_unique = list(set(l_flat))
        return l_unique

    def _mean(numbers):
        return float(sum(numbers)) / max(len(numbers), 1)

    def _merge_response_times(response_times):
        flat_list = []
        for r_time in response_times:
            for key, value in r_time.items():
                flat_list.extend([int(float(key))] * value)
        hist, bins = histogram(flat_list)
        return {
            'histogram': hist.tolist(),
            'bins': bins.tolist(),
        }

    def _get_min(data, key):
        try:
            return min([r[key] for r in data if r[key] is not None])
        except ValueError:
            return 0

    def _get_max(data, key):
        try:
            return max([r[key] for r in data if r[key] is not None])
        except ValueError:
            return 0

    def _calculate_aws_lambda_cost(total_execution_time, memory_limit, invocation_count):
        dollar_cost_per_128mb_100ms = 0.000000208
        dollar_cost_per_invocation = 0.0000002
        memory_cost_multiplier = int(memory_limit) / 128.0
        time_in_100ms_lots = int(total_lambda_execution_time / 100.0)
        invocation_cost = invocation_count * 0.0000002
        execution_time_cost = time_in_100ms_lots * dollar_cost_per_128mb_100ms * memory_cost_multiplier
        return (invocation_cost + execution_time_cost)

    request_tasks = _flatten_unique([list(stat['requests'].keys()) for stat in results])
    failed_tasks = _flatten_unique([list(stat['failures'].keys()) for stat in results])
    total_lambda_execution_time = sum([(300000 - stat['remaining_time']) for stat in results])
    memory_limit = _get_max(results, 'memory_limit')

    agg_results = {
        'requests': {key: {} for key in request_tasks},
        'failures': {key: {} for key in failed_tasks},
        'num_requests': sum([stat['num_requests'] for stat in results]),
        'num_requests_fail': sum([stat['num_requests_fail'] for stat in results]),
        'total_lambda_execution_time': total_lambda_execution_time,
        'lambda_invocations': len(results),
        'approximate_cost': _calculate_aws_lambda_cost(total_lambda_execution_time, memory_limit, len(results))
    }

    for task in request_tasks:
        task_data_results = [stat['requests'][task] for stat in results if task in stat['requests']]

        for mean_stat in ['median_response_time', 'total_rps', 'avg_response_time']:
            agg_results['requests'][task][mean_stat] = _mean([data[mean_stat] for data in task_data_results])

        agg_results['requests'][task]['max_response_time'] = _get_max(task_data_results, 'max_response_time')
        agg_results['requests'][task]['min_response_time'] = _get_min(task_data_results, 'min_response_time')
        agg_results['requests'][task]['response_times'] = _merge_response_times([data['response_times'] for data in task_data_results if data['response_times'] is not None])
        agg_results['requests'][task]['total_rpm'] = agg_results['requests'][task]['total_rps'] * 60
        agg_results['requests'][task]['num_requests'] = sum([stat['requests'][task]['num_requests'] for stat in results if task in stat['requests']])

    for task in failed_tasks:
        task_data_results = [stat['failures'][task] for stat in results if task in stat['failures']]
        agg_results['failures'][task] = task_data_results[0]
        agg_results['failures'][task]['occurences'] = sum([stat['occurences'] for stat in task_data_results])

    return agg_results