Return benchmark performance in GOPS (Gate operations per second)
483443
def benchmark_gops(N, gates, reps):
    """"""
    t = timeit.timeit(lambda: benchmark(N, gates), number=reps)
    gops = (GATES*REPS)/t
    gops = int((gops * 100) + 0.5) / 100.0
    return gops
38590
def result(self):
        """"""
        try:
            cpu_time = max(0, time.clock() - self._cpu_time_started)
            wall_time = max(0, time.time() - self._wall_time_started)
        except AttributeError:
            cpu_time = wall_time = 0.0
        return self.stats, cpu_time, wall_time
99426
def slow_iter_turns_eval_cmp(qry, oper, start_branch=None, engine=None):
    
    def mungeside(side):
        if isinstance(side, Query):
            return side.iter_turns
        elif isinstance(side, StatusAlias):
            return EntityStatAccessor(
                side.entity, side.stat, side.engine,
                side.branch, side.turn, side.tick, side.current, side.mungers
            )
        elif isinstance(side, EntityStatAccessor):
            return side
        else:
            return lambda: side
    leftside = mungeside(qry.leftside)
    rightside = mungeside(qry.rightside)
    engine = engine or leftside.engine or rightside.engine

    for (branch, _, _) in engine._iter_parent_btt(start_branch or engine.branch):
        if branch is None:
            return
        parent, turn_start, tick_start, turn_end, tick_end = engine._branches[branch]
        for turn in range(turn_start, engine.turn + 1):
            if oper(leftside(branch, turn), rightside(branch, turn)):
                yield branch, turn
743929
def benchmark_forward(self):
        
        self._setup()

        def f():
            self._forward()
            self.mod_ext.synchronize(**self.ext_kwargs)
        f()  # Ignore first
        self.forward_stat = self._calc_benchmark_stat(f)
459892
public function benchmark($iterations = 10000, $inputSize = null)
    {
        $set = new BenchmarkResultsSet($iterations, $inputSize);
        $this->resultsGroup->addSet($set);

        foreach ($this->getSamplersForInputSize($inputSize) as $name => $func) {
            $actualIterations = $this->getActualIterations($name, $iterations, $inputSize);

            $start = microtime(true);
            for ($i = 0; $i < $actualIterations; $i++)
                $func();
            $time = microtime(true) - $start;

            $set->addBenchmark(new Benchmark($name, $time, $actualIterations));
        }

        return $this;
    }
215921
def benchmark():
    
    # Use all cores but one on multi-core CPUs.
    pool_size = multiprocessing.cpu_count() - 1
    if pool_size < 1:
        pool_size = 1

    # Start a pool of workers. Only allow 1 task per child, to force flushing
    # of solver's internal caches.
    pool = multiprocessing.Pool(processes=pool_size, maxtasksperchild=1)
    results = pool.imap_unordered(run_scenario, Benchmark.scenarii)
    pool.close()
    pool.join()

    # Update CSV database with the new results.
    benchmark = Benchmark()
    benchmark.load_csv()
    benchmark.add(results)
    benchmark.save_csv()
284446
def benchmark_mitdb_record(rec, detector, verbose):
    
    sig, fields = rdsamp(rec, pb_dir='mitdb', channels=[0])
    ann_ref = rdann(rec, pb_dir='mitdb', extension='atr')

    qrs_inds = detector(sig=sig[:,0], fs=fields['fs'], verbose=verbose)

    comparitor = compare_annotations(ref_sample=ann_ref.sample[1:],
                                     test_sample=qrs_inds,
                                     window_width=int(0.1 * fields['fs']))
    if verbose:
        print('Finished record %s' % rec)
    return comparitor
60444
def benchmark(f, n_repeats=3, warmup=True, name=""):
    
    if warmup:
        f()

    total_time = 0
    for i in range(n_repeats):
        iter_name = "%s (iter #%d)" % (name, i + 1,)
        with Timer(iter_name) as t:
            f()
        total_time += t.elapsed
    return total_time / n_repeats
704228
function bench(functions, options) {
  const funcs = assertFunctions(functions);
  const opts = assertOptions(options);
  const metrics = [];
  const totalRuns = funcs.length * opts.runs;
  let runCount = 0;

  for (let i = 0; i < funcs.length; i++) {
    const func = funcs[i];
    const totals = [0, 0];
    let max = 0;
    let min = Number.MAX_SAFE_INTEGER;

    for (let j = 0; j < opts.runs; j++) {
      const start = process.hrtime();
      func.fn.call(func.bind, func.params);
      const end = process.hrtime(start);

      totals[0] += end[0];
      totals[1] += end[1];

      const ns = (end[0] * NS_PER_SEC) + end[1];
      if (ns > max) max = ns;
      if (ns < min) min = ns;

      updateStatus(++runCount, totalRuns, opts.stream);
    }

    const whole = (totals[0] / opts.runs) * NS_PER_SEC;
    const partial = totals[1] / opts.runs;
    const avg = Math.ceil(whole + partial);

    metrics.push({
      avg,
      label: func.label,
      max,
      min,
    });
  }

  opts.report(opts.stream, metrics, opts.thresholds);
  checkThresholds(metrics, opts.thresholds);

  return metrics;
}
1217398
function runStep(step) 
{
  switch (step) {
    case 1 : 
      trace("-- Beginning benchmark --");
      initializeDB();
      initializeUnique();
      setTimeout(function() { runStep(2); }, 100);
      break;
    case 2 : 
      benchGet();
      setTimeout(function() { runStep(3); }, 100);
      break;
    case 3 :
      benchUniquePerf();
      setTimeout(function() { runStep(4); }, 100);
      trace("");
      trace("-- Benchmarking query on non-indexed column --");
      break;
    case 4 : 
      benchFind();	// find benchmark on unindexed customid field
      setTimeout(function() { runStep(5); }, 100);
      break;
    case 5 : 
      benchRS(); // resultset find benchmark on unindexed customid field
      setTimeout(function() { runStep(6); }, 100);
      break;
    case 6 : 
      benchDV();
      setTimeout(function() { runStep(7); }, 100);
      trace("");
      trace("-- Adding Binary Index to query column and repeating benchmarks --");
      break;
    case 7 : 
      samplecoll.ensureIndex("customId");
      setTimeout(function() { runStep(8); }, 100);
      break;
    case 8 : 
      benchFind(20);
      setTimeout(function() { runStep(9); }, 100);
      break;
    case 9 : 
      benchRS(15);
      setTimeout(function() { runStep(10); }, 100);
      break;
    case 10 : 
      benchDV(15);
      trace("");
      trace("done.");
      break;
  }
}
372117
private function Benchmark($st) {
    $val = (microtime(true) - $st);
    if ($val >= 1) {
      return number_format($val, 2, '.', ',').' sec';
    }
    $val = $val * 1000;
    if ($val >= 1) {
      return number_format($val, 2, '.', ',').' msec';
    }
    $val = $val * 1000;
    return number_format($val, 2, '.', ',').' μsec';
  }
1369578
def _find_benchmarks(self):
        """"""
        def is_bench_method(attrname, prefix="bench"):
            return attrname.startswith(prefix) and hasattr(getattr(self.__class__, attrname), '__call__')
        return list(filter(is_bench_method, dir(self.__class__)))
256254
def pefficiency(self):
        
        timers = self.timers()

        # Number of CPUs employed in each calculation.
        ncpus = [timer.ncpus for timer in timers]

        # Find the minimum number of cpus used and its index in timers.
        min_idx = minloc(ncpus)
        min_ncpus = ncpus[min_idx]

        # Reference timer
        ref_t = timers[min_idx]

        # Compute the parallel efficiency (total and section efficiency)
        peff = {}
        ctime_peff = [(min_ncpus * ref_t.wall_time) / (t.wall_time * ncp) for (t, ncp) in zip(timers, ncpus)]
        wtime_peff = [(min_ncpus * ref_t.cpu_time) / (t.cpu_time * ncp) for (t, ncp) in zip(timers, ncpus)]
        n = len(timers)

        peff["total"] = {}
        peff["total"]["cpu_time"] = ctime_peff
        peff["total"]["wall_time"] = wtime_peff
        peff["total"]["cpu_fract"] = n * [100]
        peff["total"]["wall_fract"] = n * [100]

        for sect_name in self.section_names():
            #print(sect_name)
            ref_sect = ref_t.get_section(sect_name)
            sects = [t.get_section(sect_name) for t in timers]
            try:
                ctime_peff = [(min_ncpus * ref_sect.cpu_time) / (s.cpu_time * ncp) for (s, ncp) in zip(sects, ncpus)]
                wtime_peff = [(min_ncpus * ref_sect.wall_time) / (s.wall_time * ncp) for (s, ncp) in zip(sects, ncpus)]
            except ZeroDivisionError:
                ctime_peff = n * [-1]
                wtime_peff = n * [-1]

            assert sect_name not in peff
            peff[sect_name] = {}
            peff[sect_name]["cpu_time"] = ctime_peff
            peff[sect_name]["wall_time"] = wtime_peff

            peff[sect_name]["cpu_fract"] = [s.cpu_fract for s in sects]
            peff[sect_name]["wall_fract"] = [s.wall_fract for s in sects]

        return ParallelEfficiency(self._filenames, min_idx, peff)
344250
def benchmark(message)
      start = Time.now
      print(stdout, "#{message} ")
      result = yield
      duration = Time.now - start
      info("✔".green + format(" %0.3fs", duration).gray)
      result
    rescue
      info("✘".red)
      raise
    end
1128378
function Benchmark(name, fn) {
  this._name = name;
  this._fn = fn;
  this._async = fn.length > 1;
}
619456
function runWithProgress(maybeTaskFn, inSuite)
	{
            
	    return Task.asyncFunction(function(callback) {
                var bjsSuite = new Benchmark.Suite;
                var benchArray;
                var retData = [];
                var finalString = "";
                var numCompleted = 0;
                var numToRun;
                
                switch (inSuite.ctor)
                {
                    case "Suite":
                      benchArray = List.toArray(inSuite._1);
                      break;
                    case "SingleBenchmark":
                      benchArray = [inSuite._0 ];
                      break;
                }

                numToRun = benchArray.length;
                Task.perform(maybeTaskFn("Running benchmark 1 of " + numToRun));

                //Initialize each benchmark in the suite
                for (i = 0; i < benchArray.length; i++)
                {
                    var ourThunk = function (){
                        //Run the thing we're timing, then mark the asynch benchmark as done
                        benchArray[i].thunk();
                        deferred.resolve();
                        }
                    bjsSuite.add(benchArray[i].name, benchArray[i].thunk );
                }

                //Every time a benchmark finishes, we store its results
                //and update our progress string
                bjsSuite.on('cycle', function(event) {
                   numCompleted += 1;
                   retData.push(
                       { name : event.target.options.name
                       , hz : event.target.hz
                       , marginOfError : event.target.stats.moe
                       , moePercent : event.target.stats.rme
                       }
                       );
                   finalString += String(event.target) + "\n";
                   var intermedString = 
                        "Running benchmark " 
                        + (numCompleted + 1) 
                        + " of " + numToRun 
                        + "\nLast result: " + String(event.target);
                   Task.perform(maybeTaskFn(intermedString));
                   //retString += String(event.target) + "\n";
                });
                
                //When the last benchmark finishes, we show all results collected
                bjsSuite.on('complete', function(event) {
                   Task.perform(maybeTaskFn("Final results:\n\n" + finalString) );
                   return callback(Task.succeed(Utils.Tuple2(finalString, List.fromArray(retData))));
                });

                //Finally: actually run the suite
                Task.perform(
                  Task.asyncFunction(function(otherCallback){
                      bjsSuite.run({ 'async': true });
                  }));
        });
             }
759662
public function benchmark($callable, array $params = array())
	{
		// get the before-benchmark time
		list($usec, $sec) = explode(" ", microtime());
		$time_before = ((float)$usec + (float)$sec);

		// call the function to be benchmarked
		$result = is_callable($callable) ? call_user_func_array($callable, $params) : null;

		// get the after-benchmark time
		list($usec, $sec) = explode(" ", microtime());
		$time_after = ((float)$usec + (float)$sec);

		return array(
			'time' => sprintf('%1.6f', $time_after - $time_before),
			'result' => $result
		);
	}