Generates statistics from the timing summaries
556170
def _analyze_case(model_dir, bench_dir, config):
    
    model_timings = set(glob.glob(os.path.join(model_dir, "*" + config["timing_ext"])))
    if bench_dir is not None:
        bench_timings = set(glob.glob(os.path.join(bench_dir, "*" + config["timing_ext"])))
    else:
        bench_timings = set()
    if not len(model_timings):
        return dict()
    model_stats = generate_timing_stats(model_timings, config['timing_vars'])
    bench_stats = generate_timing_stats(bench_timings, config['timing_vars'])
    return dict(model=model_stats, bench=bench_stats)
340776
def get_data_statistics(interpreted_files):
    '''
    '''
    print '| *File Name* | *File Size* | *Times Stamp* | *Events* | *Bad Events* | *Measurement time* | *# SR* | *Hits* |'  # Mean Tot | Mean rel. BCID'
    for interpreted_file in interpreted_files:
        with tb.open_file(interpreted_file, mode="r") as in_file_h5:  # open the actual hit file
            n_hits = np.sum(in_file_h5.root.HistOcc[:])
            measurement_time = int(in_file_h5.root.meta_data[-1]['timestamp_stop'] - in_file_h5.root.meta_data[0]['timestamp_start'])
#             mean_tot = np.average(in_file_h5.root.HistTot[:], weights=range(0,16) * np.sum(range(0,16)))# / in_file_h5.root.HistTot[:].shape[0]
#             mean_bcid = np.average(in_file_h5.root.HistRelBcid[:], weights=range(0,16))
            n_sr = np.sum(in_file_h5.root.HistServiceRecord[:])
            n_bad_events = int(np.sum(in_file_h5.root.HistErrorCounter[2:]))
            try:
                n_events = str(in_file_h5.root.Hits[-1]['event_number'] + 1)
            except tb.NoSuchNodeError:
                n_events = '~' + str(in_file_h5.root.meta_data[-1]['event_number'] + (in_file_h5.root.meta_data[-1]['event_number'] - in_file_h5.root.meta_data[-2]['event_number']))
            else:
                print '|', os.path.basename(interpreted_file), '|', int(os.path.getsize(interpreted_file) / (1024.0 * 1024.0)), 'Mb |', time.ctime(os.path.getctime(interpreted_file)), '|', n_events, '|', n_bad_events, '|', measurement_time, 's |', n_sr, '|', n_hits, '|'
651450
def gen_time_intervals(start, end, delta):
    
    curr = start
    while curr < end:
        yield curr
        curr += delta
784392
def _post_stats(self, stats):
        '''
        
        '''
        end_time = time.time()
        if end_time - self.stat_clock > self.opts['master_stats_event_iter']:
            # Fire the event with the stats and wipe the tracker
            self.aes_funcs.event.fire_event({'time': end_time - self.stat_clock, 'worker': self.name, 'stats': stats}, tagify(self.name, 'stats'))
            self.stats = collections.defaultdict(lambda: {'mean': 0, 'latency': 0, 'runs': 0})
            self.stat_clock = end_time
640193
def _generate_time_values(self):
        
        # Populate time values
        log('writing times', 'INFO')
        d1970 = datetime(1970, 1, 1, tzinfo=utc)
        time_array = [[int((self.start_datetime - d1970).total_seconds())]]

        datetime_nc_start_simulation = self.start_datetime
        for raw_nc_index, raw_nc in enumerate(self.raw_nc_list):
            raw_nc_time = raw_nc.get_time_array(
                datetime_simulation_start=datetime_nc_start_simulation,
                simulation_time_step_seconds=self.time_step_array[
                    raw_nc_index])

            time_array.append(raw_nc_time)
            datetime_nc_start_simulation = \
                datetime.utcfromtimestamp(raw_nc_time[-1])

        self.cf_nc.variables['time'][:] = np.concatenate(time_array)
        end_date = datetime.utcfromtimestamp(self.cf_nc.variables['time'][-1])
        self.cf_nc.time_coverage_start = self.start_datetime.isoformat() + 'Z'
        self.cf_nc.time_coverage_end = end_date.isoformat() + 'Z'
42092
def make_summary_funcs(rows, ids):
    """"""
    return {
        'len': len,
        'list': lambda *x: filter(None, list(x)),
        'max': max,
        'min': min,
        'rows': partial(summary_rows, rows, ids),
        'sum': sum,
        'trace': print_trace
    }
325411
def interevent_time(records):
    
    inter_events = pairwise(r.datetime for r in records)
    inter = [(new - old).total_seconds() for old, new in inter_events]

    return summary_stats(inter)
209790
def summarize(self, n_timescales_to_report=5):
        """"""
        nonzeros = np.sum(np.abs(self.eigenvectors_) > 0, axis=0)
        active = '[%s]' % ', '.join(['%d/%d' % (n, self.n_features) for n in nonzeros[:n_timescales_to_report]])

        return """K-sparse time-structure Independent Components Analysis (tICA)
------------------------------------------------------------------
n_components        : {n_components}
shrinkage           : {shrinkage}
lag_time            : {lag_time}
kinetic_mapping     : {kinetic_mapping}
n_features          : {n_features}
Top {n_timescales_to_report} timescales :
{timescales}
Top {n_timescales_to_report} eigenvalues :
{eigenvalues}
Number of active degrees of freedom:
{active}
""".format(n_components=self.n_components, shrinkage=self.shrinkage_, lag_time=self.lag_time,
           kinetic_mapping=self.kinetic_mapping,
           timescales=self.timescales_[:n_timescales_to_report], eigenvalues=self.eigenvalues_[:n_timescales_to_report],
           n_features=self.n_features, active=active, n_timescales_to_report=n_timescales_to_report)
693746
def _log_statistics(self):
        
        rows_per_second_trans = self._count_total / (self._time1 - self._time0)
        rows_per_second_load = self._count_transform / (self._time2 - self._time1)
        rows_per_second_overall = self._count_total / (self._time3 - self._time0)

        self._log('Number of rows processed            : {0:d}'.format(self._count_total))
        self._log('Number of rows transformed          : {0:d}'.format(self._count_transform))
        self._log('Number of rows ignored              : {0:d}'.format(self._count_ignore))
        self._log('Number of rows parked               : {0:d}'.format(self._count_park))
        self._log('Number of errors                    : {0:d}'.format(self._count_error))
        self._log('Number of rows per second processed : {0:d}'.format(int(rows_per_second_trans)))
        self._log('Number of rows per second loaded    : {0:d}'.format(int(rows_per_second_load)))
        self._log('Number of rows per second overall   : {0:d}'.format(int(rows_per_second_overall)))
898762
def _GenerateStaticsTable(self, title='Current Statistics'):
        """"""
        if len(self.__categories.keys()) < 1:
            return ''
        d = self.__categories
        keys = sorted(d.keys())
        cats = ', '.join(['"%s"' % k for k in keys])
        vals = ', '.join(['%d' % d[k] for k in keys])

        return r'''

%s
%s

.. csv-table::
   :header: %s

   %s

''' % (title, '-'*len(title), cats, vals)
1342510
private void generateSummaryData(List<ISuite> suites) {
        logger.entering(suites);

        SummarizedData tempSuite;
        SummarizedData tempTest;
        SummarizedData tempGroups;
        this.generateTestCaseResultData(suites);

        // Generating Group Summary data
        for (ISuite suite : suites) {

            tempSuite = new SummarizedData();
            tempSuite.setsName(suite.getName());
            Map<String, ISuiteResult> allResults = suite.getResults();
            for (Entry<String, Collection<ITestNGMethod>> sGroupName : suite.getMethodsByGroups().entrySet()) {
                tempGroups = new SummarizedData();
                tempGroups.setsName(sGroupName.getKey());
                tempGroups.incrementiTotal(sGroupName.getValue().size());

                for (TestCaseResult tr : allTestsResults) {
                    if (tr.getGroup().contains(sGroupName.getKey())) {
                        tempGroups.incrementCount(tr.getStatus());
                        tempGroups.incrementDuration(tr.getDurationTaken());
                    }
                }
                tempGroups.setiTotal(tempGroups.getiPassedCount() + tempGroups.getiFailedCount()
                        + tempGroups.getiSkippedCount());
                lGroups.add(tempGroups);

            }

            // Generating Test summary data
            for (ISuiteResult testResult : allResults.values()) {
                ITestContext testContext = testResult.getTestContext();
                tempTest = new SummarizedData();
                tempTest.setsName(testContext.getName());
                tempTest.setiFailedCount(testContext.getFailedTests().size());
                tempTest.setiPassedCount(testContext.getPassedTests().size());
                tempTest.setiSkippedCount(testContext.getSkippedTests().size());
                tempTest.setiTotal(tempTest.getiPassedCount() + tempTest.getiFailedCount()
                        + tempTest.getiSkippedCount());
                tempTest.setlRuntime(testContext.getEndDate().getTime() - testContext.getStartDate().getTime());

                lTests.add(tempTest);
            }

            // Generating Suite Summary data
            for (SummarizedData test : lTests) {

                tempSuite.setiPassedCount(test.getiPassedCount() + tempSuite.getiPassedCount());
                tempSuite.setiFailedCount(test.getiFailedCount() + tempSuite.getiFailedCount());
                tempSuite.setiSkippedCount(tempSuite.getiSkippedCount() + test.getiSkippedCount());
                tempSuite.setiTotal(tempSuite.getiPassedCount() + tempSuite.getiFailedCount()
                        + tempSuite.getiSkippedCount());
                tempSuite.setlRuntime(test.getlRuntime() + tempSuite.getlRuntime());
            }
            lSuites.add(tempSuite);

        }

        Collections.sort(lGroups);
        Collections.sort(lTests);
        logger.exiting();
    }
312774
def _generate_report(ret, show_tasks):
    '''
    
    '''

    returns = ret.get('return')

    sorted_data = sorted(
        returns.items(),
        key=lambda s: s[1].get('__run_num__', 0)
    )

    total = 0
    failed = 0
    changed = 0
    duration = 0.0

    changed_tasks = []
    failed_tasks = []

    # gather stats
    for state, data in sorted_data:
        # state: module, stateid, name, function
        _, stateid, _, _ = state.split('_|-')
        task = '{filename}.sls | {taskname}'.format(
            filename=str(data.get('__sls__')), taskname=stateid)

        if not data.get('result', True):
            failed += 1
            failed_tasks.append(task)

        if data.get('changes', {}):
            changed += 1
            changed_tasks.append(task)

        total += 1
        try:
            duration += float(data.get('duration', 0.0))
        except ValueError:
            pass

    unchanged = total - failed - changed

    log.debug('%s total: %s', __virtualname__, total)
    log.debug('%s failed: %s', __virtualname__, failed)
    log.debug('%s unchanged: %s', __virtualname__, unchanged)
    log.debug('%s changed: %s', __virtualname__, changed)

    report = {
        'id': ret.get('id'),
        'success': True if failed == 0 else False,
        'total': total,
        'function': ret.get('fun'),
        'arguments': ret.get('fun_args', []),
        'jid': ret.get('jid'),
        'duration': duration / 1000,
        'unchanged': {
            'counter': unchanged
        },
        'changed': {
            'counter': changed,
            'tasks': changed_tasks if show_tasks else []
        },
        'failed': {
            'counter': failed,
            'tasks': failed_tasks if show_tasks else []
        }
    }

    return report
1261445
function process(raw) {
  var stats = {
    counters : raw.counters,
    gauges   : raw.gauges,
    sets     : {},
    timers   : {},
    ts       : raw.ts,
    info     : raw.info,
  }

  // process some stats so the backends don't have to
  var timerKeys = Object.keys(raw.timers || {})
  timerKeys.forEach(function(timer) {
    // see if we have any data
    if ( raw.timers[timer].length === 0 ) {
      stats.timers[timer] = {}
    }

    // yes, got some timings, sort them first
    var times = raw.timers[timer].sort(function(a, b) { return a - b })

    // calculate some stats per timer
    var data = {
      sum   : times.reduce(function(a, b) { return a + b }),
      count : times.length,
      min   : times[0],
      max   : times[times.length-1],
    }
    data.mean = data.sum / data.count

    // find the median
    var middle = Math.floor(data.count/2)
    // take the middle value, or the average of the middle two
    var median = (data.count % 2) ? times[middle] : (times[middle-1] + times[middle])/2
    data.median = median

    // find the standard deviation
    var sumOfDiffs = 0
    for (var i = 0; i < data.count; i++) {
      sumOfDiffs += (times[i] - data.mean) * (times[i] - data.mean)
    }
    data.std = Math.sqrt(sumOfDiffs / data.count)

    stats.timers[timer] = data
  })

  var setsKeys = Object.keys(raw.sets || {})
  setsKeys.forEach(function(set) {
    var info = {
      // bottom : 0,
      // top    : 0,
      unique : 0,
      total  : 0,
    }

    // see how many keys this set has
    var keys = Object.keys(raw.sets[set])

    // get the uniques
    info.unique = keys.length

    // get the total
    info.total = keys.reduce(function(sum, key) {
      return sum + raw.sets[set][key]
    }, 0)

    stats.sets[set] = info
  })

  return stats
}
1136537
def _GenerateSummary(self):
    
    items = []
    if self._notices:
      items.append('notices: %d' % self._notice_count)
    if self._dataset_errors:
      items.append('errors: %d' % self._error_count)
    if self._dataset_warnings:
      items.append('warnings: %d' % self._warning_count)

    if items:
      return '<p><span class="fail">%s</span></p>' % '<br>'.join(items)
    else:
      return '<p><span class="pass">feeds merged successfully</span></p>'
49637
def print_summary(self, result, time_taken):
        
        if hasattr(result, "separator2"):
            self.stream.writeln(result.separator2)

        self.stream.writeln("Ran {number_of_tests} test{s} in {time:.3f}s\n".format(
            number_of_tests=result.testsRun, s="s" if result.testsRun != 1 else "", time=time_taken
        ))

        info = []
        if not result.wasSuccessful():
            self.stream.write("FAILED")

            if result.failures:
                info.append("failures={}".format(len(result.failures)))
            if result.errors:
                info.append("errors={}".format(len(result.errors)))
        else:
            self.stream.write("OK")

        if result.skipped:
            info.append("skipped={}".format(len(result.skipped)))
        if result.expectedFailures:
            info.append("expected failures={}".format(len(result.expectedFailures)))
        if result.unexpectedSuccesses:
            info.append("unexpected successes={}".format(len(result.unexpectedSuccesses)))

        if info:
            self.stream.writeln(" ({})".format(", ".join(info)))
        else:
            self.stream.write("\n")
800433
def summarize(group, fs=None, include_source=True):
        
        _line_break = '{0:-<120}\n'.format('')
        tests = sorted(ComparisonBenchmark.groups[group], key=lambda t: getattr(t, 'time_average_seconds'))
        log = StringIO.StringIO()
        log.write('Call statement:\n\n')
        log.write('\t' + tests[0].stmt)
        log.write('\n\n\n')
        fmt = "{0: <8} {1: <35} {2: <12} {3: <15} {4: <15} {5: <14}\n"
        log.write(fmt.format('Rank', 'Function Name', 'Time', '% of Slowest', 'timeit_repeat', 'timeit_number'))
        log.write(_line_break)
        log.write('\n')

        for i, t in enumerate(tests):
            func_name = "{}.{}".format(t.classname, t.callable.__name__) if t.classname else t.callable.__name__
            if i == len(tests)-1:
                time_percent = 'Slowest'
            else:
                time_percent = "{:.1f}".format(t.time_average_seconds / tests[-1].time_average_seconds * 100)
            log.write(fmt.format(i+1,
                                 func_name,
                                 convert_time_units(t.time_average_seconds),
                                 time_percent,
                                 t.timeit_repeat,
                                 t.timeit_number))
        log.write(_line_break)

        if include_source:
            log.write('\n\n\nSource Code:\n')
            log.write(_line_break)
            for test in tests:
                log.write(test.log.getvalue())
                log.write(_line_break)

        if isinstance(fs, str):
            with open(fs, 'w') as f:
                f.write(log.getvalue())

        elif fs is None:
            print(log.getvalue())
        else:
            try:
                fs.write(log.getvalue())
            except AttributeError as e:
                print(e)
1236707
private void statistics(Word word, int times, Map<String, AtomicInteger> container){
        statistics(word.getText(), times, container);
    }