Run benchmark case once and output results.
181198
def run_once
      self.class.run_count(self.class.run_count + 1)
      self.class.output.puts Time.now.strftime(' %FT%T %Z ').center(COLUMNS, '=')
      self.class.output.puts "Benchmarking on #{RUBY_DESCRIPTION}."
      self.class.output.puts self.class.message
      self.class.output.puts '=' * COLUMNS, ''
      @clocks.clear
      if self.class.warmup == :aggressive
        self.class.output.puts "Aggressively run all benchmarks for warmup first.", ''
        bmethods.each do |bc_method|
          GC.start
          clock = run_method bc_method
          self.class.output.puts evaluation(clock)
          GC.start
        end
        self.class.output.puts "Aggressive warmup done.", '', '=' * COLUMNS, ''
      end
      first = true
      bmethods.each do |bc_method|
        if first
          first = false
        else
          self.class.output.puts '-' * COLUMNS, ''
        end
        if self.class.warmup
          self.class.output.puts "This first run is only for warmup."
          GC.start
          clock = run_method bc_method
          self.class.output.puts evaluation(clock)
          GC.start
        end
        clock = run_method(bc_method)
        if self.class.truncate_data.enabled
          message = ''
          offset = clock.find_truncation_offset
          if clock.case.data_file
            slopes_file_path = clock.file_path 'slopes'
            message << "Writing slopes data file '#{slopes_file_path}'.\n"
            File.open(slopes_file_path, 'w') do |slopes_file|
              slopes_file.puts %w[#scatter slope] * "\t"
              slopes_file.puts clock.slopes.map { |s| s * "\t" }
            end
          end
          case offset
          when 0
            message << "No initial data truncated.\n =>"\
              " System may have been in a steady state from the beginning."
          when clock.repeat
            message << "After truncating measurements no data would have"\
              " remained.\n => No steady state could be detected."
          else
            if clock.case.data_file
              data_file_path = clock.file_path 'untruncated'
              message << "Writing untruncated measurement data file '#{data_file_path}'.\n"
              File.open(data_file_path, 'w') do |data_file|
                data_file.puts clock.class.to_a * "\t"
                data_file.puts clock.to_a.map { |times| times * "\t" }
              end
            end
            remaining = clock.repeat - offset
            offset_percentage = 100 * offset.to_f / clock.repeat
            message << sprintf("Truncated initial %u measurements: "\
              "%u -> %u (-%0.2f%%).\n", offset, clock.repeat, remaining,
              offset_percentage)
            clock.truncate_data(offset)
          end
          self.class.output.puts evaluation(clock), message
        else
          self.class.output.puts evaluation(clock)
        end
        @clocks << clock
        if @comparison
          @comparison.benchmark(self, bc_method.short_name, :run => false)
        end
      end
      @clocks
    end
261863
def run(self):
        """"""
        (task_id, tasks) = self.server.get_task()
        self.task_store.from_dict(tasks)
        for (index, task) in self.task_store:
            result = self.compute(index, task)
            self.results.append(result)
        self.server.task_done((task_id, self.results))
871919
def run(self):
    """"""
    while not self._abort:
      hashes = self._GetHashes(self._hash_queue, self.hashes_per_batch)
      if hashes:
        time_before_analysis = time.time()
        hash_analyses = self.Analyze(hashes)
        current_time = time.time()
        self.seconds_spent_analyzing += current_time - time_before_analysis
        self.analyses_performed += 1
        for hash_analysis in hash_analyses:
          self._hash_analysis_queue.put(hash_analysis)
          self._hash_queue.task_done()
        time.sleep(self.wait_after_analysis)
      else:
        # Wait for some more hashes to be added to the queue.
        time.sleep(self.EMPTY_QUEUE_WAIT_TIME)
215867
def benchmark(N, gates):
    """"""
    qubits = list(range(0, N))
    ket = qf.zero_state(N)

    for n in range(0, N):
        ket = qf.H(n).run(ket)

    for _ in range(0, (gates-N)//3):
        qubit0, qubit1 = random.sample(qubits, 2)
        ket = qf.X(qubit0).run(ket)
        ket = qf.T(qubit1).run(ket)
        ket = qf.CNOT(qubit0, qubit1).run(ket)

    return ket.vec.tensor
295847
def run_benchmark(monitor):
    '''
    '''
    url = urlparse(monitor.cfg.test_url)
    name = slugify(url.path) or 'home'
    name = '%s_%d.csv' % (name, monitor.cfg.workers)
    monitor.logger.info('WRITING RESULTS ON "%s"', name)
    total = REQUESTS//monitor.cfg.workers

    with open(name, 'w') as csvfile:
        writer = csv.DictWriter(csvfile, fieldnames=FIELDNAMES)
        writer.writeheader()
        for pool_size in POOL_SIZES:
            size = pool_size//monitor.cfg.workers
            if size*monitor.cfg.workers != pool_size:
                monitor.logger.error('Adjust workes so that pool sizes '
                                     'can be evenly shared across them')
                monitor._loop.stop()

            # WORMUP
            requests = [monitor.send(worker, 'run', wormup, size, total) for
                        worker in monitor.managed_actors]
            yield from wait(requests)

            # BENCHMARK
            requests = [monitor.send(worker, 'run', bench) for
                        worker in monitor.managed_actors]
            results, pending = yield from wait(requests)
            assert not pending, 'Pending requets!'
            results = [r.result() for r in results]

            summary = {'concurrency': pool_size}
            for name in results[0]:
                summary[name] = reduce(add(name), results, 0)
            writer.writerow(summary)

            persec = summary['requests']/summary['time']
            monitor.logger.info('%d concurrency - %d requests - '
                                '%d errors - %.3f seconds - '
                                '%.2f requests/sec',
                                pool_size,
                                summary['requests'],
                                summary['errors'],
                                summary['time'],
                                persec)
520262
def run(pipeline_id, verbose, use_cache, dirty, force, concurrency, slave):
    """"""
    exitcode = 0

    running = []
    progress = {}

    def progress_cb(report):
        pid, count, success, *_, stats = report

        print('\x1b[%sA' % (1+len(running)))
        if pid not in progress:
            running.append(pid)
        progress[pid] = count, success

        for pid in running:
            count, success = progress[pid]
            if success is None:
                if count == 0:
                    print('\x1b[2K%s: \x1b[31m%s\x1b[0m' % (pid, 'WAITING FOR OUTPUT'))
                else:
                    print('\x1b[2K%s: \x1b[33mRUNNING, processed %s rows\x1b[0m' % (pid, count))
            else:
                if success:
                    print('\x1b[2K%s: \x1b[32mSUCCESS, processed %s rows\x1b[0m' % (pid, count))
                else:
                    print('\x1b[2K%s: \x1b[31mFAILURE, processed %s rows\x1b[0m' % (pid, count))

    results = run_pipelines(pipeline_id, '.', use_cache,
                            dirty, force, concurrency,
                            verbose, progress_cb if not verbose else None,
                            slave)
    if not slave:
        logging.info('RESULTS:')
        errd = False
        for result in results:
            stats = user_facing_stats(result.stats)
            errd = errd or result.errors or not result.success
            logging.info('%s: %s %s%s',
                         'SUCCESS' if result.success else 'FAILURE',
                         result.pipeline_id,
                         repr(stats) if stats is not None else '',
                         (
                            '\nERROR log from processor %s:\n+--------\n| ' % result.errors[0] +
                            '\n| '.join(result.errors[1:]) +
                            '\n+--------'
                         ) if result.errors else '')
    else:
        result_obj = []
        errd = False
        for result in results:
            errd = errd or result.errors or not result.success
            stats = user_facing_stats(result.stats)
            result_obj.append(dict(
                success=result.success,
                pipeline_id=result.pipeline_id,
                stats=result.stats,
                errors=result.errors
            ))
            json.dump(result_obj, sys.stderr)

    if errd:
        exitcode = 1

    exit(exitcode)
204321
function (benchmark, simultaneousRequests, done) {
	var pageName,
		engineName;

	this.benchmark = benchmark;
	this.simultaneousRequests = simultaneousRequests;
	this.done = done;

	if (typeof simultaneousRequests !== "number") {
		throw new Error("simultaneousRequests must be an integer; " + (typeof simultaneousRequests) + " passed");
	}
	if (simultaneousRequests < 1) {
		throw new Error("simultaneousRequests must be at least 1; " + simultaneousRequests + " passed");
	}

	this.responseTimes = {};
	for (pageName in this.benchmark.pages) {
		this.responseTimes[pageName] = {};
		for (engineName in this.benchmark.engines) {
			this.responseTimes[pageName][engineName] = [];
		}
	}

	this.totals = {};
}
959382
def benchmark(src_dir, compiler, include_dirs, iter_count):
    """"""

    files = list(files_in_dir(src_dir, 'cpp'))
    random.shuffle(files)
    has_string_templates = True
    string_template_file_cnt = sum(1 for file in files if 'bmp' in file)
    file_count = len(files) + string_template_file_cnt

    started_at = time.time()
    result = {}
    for filename in files:
        progress = len(result)
        result[filename] = benchmark_file(
            os.path.join(src_dir, filename),
            compiler,
            include_dirs,
            (float(progress) / file_count, float(progress + 1) / file_count),
            iter_count
        )
        if 'bmp' in filename and has_string_templates:
            try:
                temp_result = benchmark_file(
                    os.path.join(src_dir, filename),
                    compiler,
                    include_dirs,
                    (float(progress + 1) / file_count, float(progress + 2) / file_count),
                    iter_count,
                    '-Xclang -fstring-literal-templates'
                )
                result[filename.replace('bmp', 'slt')] = temp_result
            except:
                has_string_templates = False
                file_count -= string_template_file_cnt
                print 'Stopping the benchmarking of string literal templates'

        elapsed = time.time() - started_at
        total = float(file_count * elapsed) / len(result)
        print 'Elapsed time: {0}, Remaining time: {1}'.format(
            format_time(elapsed),
            format_time(total - elapsed)
        )
    return result
1193454
async function run() {
  await benchmark(
    () => map(f => f(), createPromiseFuncs()),
    'Map (concurrency: 3)'
  );
  await benchmark(
    () => mapWithOptions(f => f(), { concurrency: 1 }, createPromiseFuncs()),
    'Map (concurrency: 1)'
  );
  await benchmark(
    () => mapSeries(f => f(), createPromiseFuncs()),
    'Map series'
  );
}
416690
def evaluate(dataloader):
    """"""
    total_L = 0.0
    total_sample_num = 0
    total_correct_num = 0
    start_log_interval_time = time.time()
    print('Begin Testing...')
    for i, ((data, valid_length), label) in enumerate(dataloader):
        data = mx.nd.transpose(data.as_in_context(context))
        valid_length = valid_length.as_in_context(context).astype(np.float32)
        label = label.as_in_context(context)
        output = net(data, valid_length)
        L = loss(output, label)
        pred = (output > 0.5).reshape((-1,))
        total_L += L.sum().asscalar()
        total_sample_num += label.shape[0]
        total_correct_num += (pred == label).sum().asscalar()
        if (i + 1) % args.log_interval == 0:
            print('[Batch {}/{}] elapsed {:.2f} s'.format(
                i + 1, len(dataloader), time.time() - start_log_interval_time))
            start_log_interval_time = time.time()
    avg_L = total_L / float(total_sample_num)
    acc = total_correct_num / float(total_sample_num)
    return avg_L, acc
1270333
function prepareAndRunBenchmarks(benchmarkPatterns, revisions) {
  // Find all benchmark tests to be run.
  let benchmarks = findFiles(LOCAL_DIR('src'), '*/__tests__/*-benchmark.js');
  if (benchmarkPatterns.length !== 0) {
    benchmarks = benchmarks.filter(benchmark =>
      benchmarkPatterns.some(pattern =>
        path.join('src', benchmark).includes(pattern)
      )
    );
  }

  if (benchmarks.length === 0) {
    console.warn(
      'No benchmarks matching: ' +
        `\u001b[1m${benchmarkPatterns.join('\u001b[0m or \u001b[1m')}\u001b[0m`
    );
    return;
  }

  const environments = revisions.map(revision => ({
    revision,
    distPath: prepareRevision(revision),
  }));
  benchmarks.forEach(benchmark => runBenchmark(benchmark, environments));
}
1117098
def run_once(f):
    ''' 
    
    '''
    def wrapper(*args, **kwargs):
        if not wrapper.has_run:
            wrapper.result = f(*args, **kwargs)
            wrapper.has_run = True
        return wrapper.result
    wrapper.has_run = False
    return wrapper
1321530
function benchBatch(targets, cb, idx) {
  idx |= 0;
  if (targets.length == 0) return cb(idx);

  var target = targets.shift();
  process.stdout.write(util.format('[%s] ', idx+1));
  try {
    main.bench(target.name, target.func);
    idx++;
  } catch (err) {
    console.log('%s failed!', target.name);
  }

  //No more targets, no need to wait
  if (targets.length == 0) return cb(idx);

  //We need to wait some seconds before the next test,
  //or the results could vary depending on the order
  setTimeout(function() {
    benchBatch(targets, cb, idx); //Yeah, recursivity...
  }, 10000);
}
823306
def main(argv=None):
    """"""
    parser = argparse.ArgumentParser(description="Benchmark driver")

    parser.add_argument("--max-records", type=int, default=100 * 1000)
    parser.add_argument("--engine", type=str, choices=("vcfpy", "pyvcf"), default="vcfpy")
    parser.add_argument("--input-vcf", type=str, required=True, help="Path to VCF file to read")
    parser.add_argument(
        "--output-vcf", type=str, required=False, help="Path to VCF file to write if given"
    )

    args = parser.parse_args(argv)
    if args.engine == "vcfpy":
        VCFPyRunner(args).run()
    else:
        PyVCFRunner(args).run()
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
1201021
def execute(self, run):
        
        self.output_handler.output_before_run(run)
        benchmark = self.benchmark

        memlimit = benchmark.rlimits.get(MEMLIMIT)

        args = run.cmdline()
        logging.debug('Command line of run is %s', args)
        run_result = \
            self.run_executor.execute_run(
                args,
                output_filename=run.log_file,
                output_dir=run.result_files_folder,
                result_files_patterns=benchmark.result_files_patterns,
                hardtimelimit=benchmark.rlimits.get(TIMELIMIT),
                softtimelimit=benchmark.rlimits.get(SOFTTIMELIMIT),
                walltimelimit=benchmark.rlimits.get(WALLTIMELIMIT),
                cores=self.my_cpus,
                memory_nodes=self.my_memory_nodes,
                memlimit=memlimit,
                environments=benchmark.environment(),
                workingDir=benchmark.working_directory(),
                maxLogfileSize=benchmark.config.maxLogfileSize,
                files_count_limit=benchmark.config.filesCountLimit,
                files_size_limit=benchmark.config.filesSizeLimit)

        if self.run_executor.PROCESS_KILLED:
            # If the run was interrupted, we ignore the result and cleanup.
            try:
                if benchmark.config.debug:
                    os.rename(run.log_file, run.log_file + ".killed")
                else:
                    os.remove(run.log_file)
            except OSError:
                pass
            return 1

        if self.my_cpus:
            run_result['cpuCores'] = self.my_cpus
        if self.my_memory_nodes:
            run_result['memoryNodes'] = self.my_memory_nodes

        run.set_result(run_result)
        self.output_handler.output_after_run(run)
728485
def benchmark_method(f):
    ""
    @wraps(f)
    def inner(name, *args, **kwargs):
        return Benchmark(name, f, args, kwargs)
    return inner