Calculate the overall counts of best, worst, fastest, slowest, total
        found, total not found and total runtime

        Results are returned in a dictionary with the above parameters as keys.
326125
def calculate(self):
        
        best, worst, fastest, slowest = (), (), (), ()
        found = notfound = total_time = 0
        for source, rec in self.source_stats.items():
            if not best or rec.successes > best[1]:
                best = (source, rec.successes, rec.success_rate())
            if not worst or rec.successes < worst[1]:
                worst = (source, rec.successes, rec.success_rate())

            avg_time = self.avg_time(source)
            if not fastest or (avg_time != 0 and avg_time < fastest[1]):
                fastest = (source, avg_time)
            if not slowest or (avg_time != 0 and avg_time > slowest[1]):
                slowest = (source, avg_time)

            found += rec.successes
            notfound += rec.fails
            total_time += sum(rec.runtimes)

        return {
            'best': best,
            'worst': worst,
            'fastest': fastest,
            'slowest': slowest,
            'found': found,
            'notfound': notfound,
            'total_time': total_time
        }
34982
def _get_aggregated_info(self):
        
        agg_results = {}
        for key in self.aggregated_info['occurrences']:
            agg_results[key] = {
                'occurrences': self.aggregated_info['occurrences'].get(key),
                'coverage': (float(self.aggregated_info['occurrences']
                                   .get(key))/float(self.get_metadata('items_count')))*100
            }
        return agg_results
100417
def getResultsTotalCount(self):
        
        count = 0
        for val in self.getRawResults().values():
            count += len(val)
        return count
383257
def get_summary(name)
      counts = {}
      @cassandra.get_range(:totals, {:start => '', :finish => '', :count => @max_classes}).each do |key_slice|
        # keyslice is a clunky thrift object, map into a ruby hash
        row = key_slice.columns.inject({}){|hsh, c| hsh[c.column.name] = c.column.value; hsh}
        counts[key_slice.key.to_sym] = row[name].to_f
      end
      counts
    end
696833
def stats(self):
        
        res = {}
        db = self._collection.database
        res['dbstats'] = db.command('dbstats')
        res['data'] = db.command('collstats', self._collection.name)
        res['totals'] = {'count': res['data']['count'],
                         'size': res['data']['size']
                         }
        return res
237135
def get_count(self, prefix=''):
        """"""
        return sum([self.counters[key]
                    for key in self.messages if key.startswith(prefix)])
594162
def _facet_counts(items):
    
    facets = {}
    for name, data in items:
        facets[name] = FacetResult(name, data)
    return facets
1197202
def stats(self):
        """"""
        load_count = self.last_level_load.MISS_count
        load_byte = self.last_level_load.MISS_byte

        if self.last_level_load.victims_to is not None:
            # If there is a victim cache between last_level and memory, subtract all victim hits
            load_count -= self.last_level_load.victims_to.HIT_count
            load_byte -= self.last_level_load.victims_to.HIT_byte

        return {'name': self.name,
                'LOAD_count': load_count,
                'LOAD_byte': load_byte,
                'HIT_count': load_count,
                'HIT_byte': load_byte,
                'STORE_count': self.last_level_store.EVICT_count,
                'STORE_byte': self.last_level_store.EVICT_byte,
                'EVICT_count': 0,
                'EVICT_byte': 0,
                'MISS_count': 0,
                'MISS_byte': 0}
1154227
def get_run_summary(self, run_stats):
        
        run_stats = run_stats.copy()
        run_stats['files'] = len(run_stats['files'])
        summary = [
            u'\n--- %s run summary ---' % __package__,
            u'Number of processed files: %(files)d',
            u'Total lines read: %(lines)d',
            u'Total log events matched: %(matches)d',
        ]
        if any([app.matches or app.unparsed for app in self.apps.values()]):
            if self.matcher == 'unruled':
                summary.append("Applications found (application rules not used):")
                for app in filter(lambda x: x.matches, self.apps.values()):
                    summary.append(u'  %s(matches=%d)' % (app.name, app.matches))
            else:
                summary.append("Applications found:")
                for app in filter(lambda x: x.matches or x.unparsed, self.apps.values()):
                    summary.append(u'  %s(matches=%d, unparsed=%s)' % (app.name, app.matches, app.unparsed))
        summary.append('\n')
        return '\n'.join(summary) % run_stats
945272
def get_points(self):
        
        return [(k, self.runtime._ring[k]) for k in self.runtime._keys]
622115
def stats(self):
        
        ret = '{name}:\n' \
            '  sample_num={sample_num}, batch_num={batch_num}\n' \
            '  key={bucket_keys}\n' \
            '  cnt={bucket_counts}\n' \
            '  batch_size={bucket_batch_sizes}'\
            .format(name=self.__class__.__name__,
                    sample_num=len(self._lengths),
                    batch_num=len(self._batch_infos),
                    bucket_keys=self._bucket_keys,
                    bucket_counts=[len(sample_ids) for sample_ids in self._bucket_sample_ids],
                    bucket_batch_sizes=self._bucket_batch_sizes)
        return ret
551753
def sorted_stats(self):
        """"""
        key = self.get_key()
        return sorted(self.stats, key=lambda stat: tuple(map(
            lambda part: int(part) if part.isdigit() else part.lower(),
            re.split(r"(\d+|\D+)", self.has_alias(stat[key]) or stat[key])
        )))
612003
function getStats(results, done) {
  const databases = results.databases;

  const keys = ['document_count', 'storage_size', 'index_count', 'index_size'];
  const stats = {};
  keys.map(function(k) {
    stats[k] = 0;
  });
  databases.map(function(db) {
    keys.map(function(k) {
      stats[k] += db[k];
    });
  });
  done(null, stats);
}
789385
def visualize_qual_stats_dict_single(D, dest, title):
    

    # first find out how many cycles were there. it is going to be about 101 for
    # hiseq runs, and 251 in miseq runs, but these values may change from run to
    # run. although all lanes are expected to have the identical number of cycles
    # the following code makes sure that the number_of_cycles variable holds the
    # longest one if there is a variation between the number of cycles between
    # lanes
    number_of_cycles = 0
    for pair in ['1', '2']:
        if pair not in D:
            continue
        for tile in D[pair]:
            if len(D[pair][tile]['mean']) > number_of_cycles:
                number_of_cycles = len(D[pair][tile]['mean'])


    fig = plt.figure(figsize = (12, 8))

    plt.rcParams.update({'axes.linewidth' : 0.9})
    plt.rc('grid', color='0.50', linestyle='-', linewidth=0.1)

    all_tiles = {'1': {'mean': [0] * number_of_cycles, 'count': [0] * number_of_cycles},
                 '2': {'mean': [0] * number_of_cycles, 'count': [0] * number_of_cycles}
                }

    for i in range(0, number_of_cycles):
        means_p1 = []
        counts_p1 = []
        means_p2 = []
        counts_p2 = []
        for tile_id in D['1']:
            tile = D['1'][tile_id]
            means_p1.append(tile['mean'][i])
            counts_p1.append(tile['count'][i])
            if '2' in D and D['2']:
                tile = D['2'][tile_id]
                means_p2.append(tile['mean'][i])
                counts_p2.append(tile['count'][i])

        all_tiles['1']['mean'][i] = numpy.mean(means_p1)
        all_tiles['1']['count'][i] = sum(counts_p1)

        if '2' in D and D['2']:
            all_tiles['2']['mean'][i] = numpy.mean(means_p2)
            all_tiles['2']['count'][i] = sum(counts_p2)

    colors = cm.get_cmap('RdYlGn', lut=256)

    plt.grid(True)

    plt.subplots_adjust(left=0.02, bottom = 0.03, top = 0.95, right = 0.98)

    plt.xticks(list(range(number_of_cycles / 10, number_of_cycles, number_of_cycles / 10)), rotation=90, size='xx-small')
    plt.ylim(ymin = 0, ymax = 42)
    plt.xlim(xmin = 0, xmax = number_of_cycles - 1)
    plt.yticks(list(range(5, 41, 5)), size='xx-small')

    plt.fill_between(list(range(0, number_of_cycles)), [42 for _ in range(0, number_of_cycles)], y2 = 0, color = colors(0), alpha = 0.2)
    plt.plot(all_tiles['1']['mean'], color = 'orange', lw = 6)

    read_number_percent_dropdown = [42 * (x / all_tiles['1']['count'][0]) for x in all_tiles['1']['count']]
    if not len(set(read_number_percent_dropdown)) <= 1:
        plt.fill_between(list(range(0, number_of_cycles)), read_number_percent_dropdown, y2 = 0, color = 'black', alpha = 0.08)

        plt.text(5, 2.5, '%s' % big_number_pretty_print(all_tiles['1']['count'][0]), alpha=0.5)
    else:
        plt.text(5, 2.5, '%s' % big_number_pretty_print(all_tiles['1']['count'][0]), alpha=0.5)

    if '2' in all_tiles and all_tiles['2']:
        plt.plot(all_tiles['2']['mean'], color = 'purple', lw = 6)

    plt.figtext(0.5, 0.97, '%s' % (title), weight = 'black', size = 'xx-large', ha = 'center')

    try:
        plt.savefig(dest + '.tiff')
    except:
        plt.savefig(dest + '.png')

    return (all_tiles['1']['mean'], all_tiles['2']['mean'])
866327
def statistic_record(self, desc=True, timeout=3, is_async=False, only_read=True, *keys):
        
        if len(keys) == 0:
            records = self._generate_statistic_records()
        else:
            records = self._generate_statistic_records_by_keys(keys)
        return sorted(records, key=lambda t: t['hit_counts'], reverse=desc)
1206383
def filter(self, run_counts, criteria):
    
    correctness = criteria['correctness']
    assert correctness.dtype == np.bool
    filtered_counts = deep_copy(run_counts)
    for key in filtered_counts:
      filtered_counts[key] = filtered_counts[key][correctness]
    return filtered_counts
1150091
def aggregate_metrics(latencies_ms, duration_ms, num_bucket):
    """"""
    overall_op_count = 0
    op_counts = {operation : len(latency) for operation,
                 latency in latencies_ms.iteritems()}
    overall_op_count = sum([op_count for op_count in op_counts.itervalues()])

    print('[OVERALL], RunTime(ms), %f' % duration_ms)
    print('[OVERALL], Throughput(ops/sec), %f' % (float(overall_op_count) /
                                                duration_ms * 1000.0))

    for operation in op_counts.keys():
        operation_upper = operation.upper()
        print('[%s], Operations, %d' % (operation_upper, op_counts[operation]))
        print('[%s], AverageLatency(us), %f' % (
            operation_upper, numpy.average(latencies_ms[operation]) * 1000.0))
        print('[%s], LatencyVariance(us), %f' % (
            operation_upper, numpy.var(latencies_ms[operation]) * 1000.0))
        print('[%s], MinLatency(us), %f' % (
            operation_upper, min(latencies_ms[operation]) * 1000.0))
        print('[%s], MaxLatency(us), %f' % (
            operation_upper, max(latencies_ms[operation]) * 1000.0))
        print('[%s], 95thPercentileLatency(us), %f' % (
            operation_upper,
            numpy.percentile(latencies_ms[operation], 95.0) * 1000.0))
        print('[%s], 99thPercentileLatency(us), %f' % (
            operation_upper,
            numpy.percentile(latencies_ms[operation], 99.0) * 1000.0))
        print('[%s], 99.9thPercentileLatency(us), %f' % (
            operation_upper,
            numpy.percentile(latencies_ms[operation], 99.9) * 1000.0))
        print('[%s], Return=OK, %d' % (operation_upper, op_counts[operation]))
        latency_array = numpy.array(latencies_ms[operation])
        for j in range(num_bucket):
            print('[%s], %d, %d' % (
                operation_upper, j,
                ((j <= latency_array) & (latency_array < (j + 1))).sum()))
        print('[%s], >%d, %d' % (operation_upper, num_bucket,
                                 (num_bucket <= latency_array).sum()))