{@inheritdoc}

@throws BenchmarkException
775620
public function benchmark($caller, $record, string $context = '')
    {
        $benchmarkID = count($this->benchmarks);
        if (is_array($record)) {
            $benchmarkID = $record[0];
        } elseif (!isset($this->benchmarks[$benchmarkID])) {
            $this->benchmarks[$benchmarkID] = [$caller, $record, $context, microtime(true)];

            //Payload
            return [$benchmarkID];
        }

        if (!isset($this->benchmarks[$benchmarkID])) {
            throw new BenchmarkException("Unpaired benchmark record '{$benchmarkID}'");
        }

        $this->benchmarks[$benchmarkID][4] = microtime(true);

        return $this->benchmarks[$benchmarkID][4] - $this->benchmarks[$benchmarkID][3];
    }
885312
def run(self, **kwargs):
        '''
        
        '''
        self.report_start()
        for bench in self.benchmarks:
            bench = bench(before=self.report_before_method,
                      after=self.report_after_method,
                      after_each=self.report_progress,
                      debug=self.debug,
                      **kwargs)
            self.report_before_class(bench)
            bench.run()
            self.report_after_class(bench)
            self.runned.append(bench)
        self.report_end()
282406
public function getAll()
    {
        $benchmarks = array();

        @reset($this->results);
        while (list($identifier, $elapsed_time) = @each($this->results)) {
            if (!isset($this->temporary[$identifier])) {
                $benchmarks[$identifier] = $elapsed_time;
            }
        }

        return $benchmarks;
    }
544812
@Override
  public int run(String[] args) throws Exception {
    parseArgs(args);
    // Create results file
    FileWriter results = new FileWriter(resultsFile, true);
    // Run all benchmarks
    int failed = 0;
    for (Method method : NNLatencyBenchmark.class.getMethods()) {
      if (method.isAnnotationPresent(Benchmark.class)) {
        results.write(method.getName() + " : ");
        try {
          setUp();
          try {
            method.invoke(this, results);
          } finally {
            tearDown();
          }
        } catch (Throwable e) {
          failed++;
          LOG.error(method.getName() + " failed with: ", e);
        }
        results.write("\n");
      }
    }
    results.close();
    return -failed;
  }
673559
@Benchmark
    public ExampleClass benchmarkJavassist() throws Exception {
        ProxyFactory proxyFactory = new ProxyFactory() {
            protected ClassLoader getClassLoader() {
                return newClassLoader();
            }
        };
        proxyFactory.setUseCache(false);
        proxyFactory.setUseWriteReplace(false);
        proxyFactory.setSuperclass(baseClass);
        proxyFactory.setFilter(new MethodFilter() {
            public boolean isHandled(Method method) {
                return method.getDeclaringClass() == baseClass;
            }
        });
        @SuppressWarnings("unchecked")
        Object instance = proxyFactory.createClass().getDeclaredConstructor().newInstance();
        ((javassist.util.proxy.Proxy) instance).setHandler(new MethodHandler() {
            public Object invoke(Object self,
                                 Method thisMethod,
                                 Method proceed,
                                 Object[] args) throws Throwable {
                return proceed.invoke(self, args);
            }
        });
        return (ExampleClass) instance;
    }
727806
public static void runWith(
      String[] args, Function<BenchmarkSettings, SmCodecBenchmarkState> benchmarkStateFactory) {

    BenchmarkSettings settings =
        BenchmarkSettings.from(args).durationUnit(TimeUnit.NANOSECONDS).build();

    SmCodecBenchmarkState benchmarkState = benchmarkStateFactory.apply(settings);

    benchmarkState.runForSync(
        state -> {
          BenchmarkTimer timer = state.timer("timer");
          BenchmarkMeter meter = state.meter("meter");
          ServiceMessageCodec messageCodec = state.messageCodec();
          ServiceMessage message = state.messageWithByteBuf();

          return i -> {
            Context timeContext = timer.time();
            Object result =
                messageCodec.encodeAndTransform(
                    message,
                    (dataByteBuf, headersByteBuf) -> {
                      ReferenceCountUtil.release(headersByteBuf);
                      return dataByteBuf;
                    });
            timeContext.stop();
            meter.mark();
            return result;
          };
        });
  }
1128578
function createBenchmark( len ) {
	var x;
	var i;

	x = new Array( len );
	for ( i = 0; i < len; i++ ) {
		x[ i ] = null; // TODO: set values
	}
	return benchmark;

	/**
	* Benchmark function.
	*
	* @private
	* @param {Benchmark} b - benchmark instance
	*/
	function benchmark( b ) {
		var i;

		b.tic();
		for ( i = 0; i < b.iterations; i++ ) {
			// TODO: synchronous task
			if ( TODO/* TODO: condition */ ) {
				b.fail( 'something went wrong' );
			}
		}
		b.toc();
		if ( TODO/* TODO: condition */ ) {
			b.fail( 'something went wrong' );
		}
		b.pass( 'benchmark finished' );
		b.end();
	}
}
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 = {};
}
728485
def benchmark_method(f):
    ""
    @wraps(f)
    def inner(name, *args, **kwargs):
        return Benchmark(name, f, args, kwargs)
    return inner
952911
public function resetAll($retainBenchmarks = array())
    {
        // If no benchmarks should be retained
        if (count($retainBenchmarks) == 0) {
            $this->results = array();
            return true;
        }

        // Else reset all benchmarks BUT the retain_benachmarks
        @reset($this->results);
        while (list($identifier) = @each($this->results)) {
            if (!in_array($identifier, $retainBenchmarks)) {
                $this->results[$identifier] = 0;
            }
        }

        return true;
    }
726005
public void runBenchmark() throws Exception {
        System.out.print(HORIZONTAL_RULE);
        System.out.println(" Setup & Initialization");
        System.out.println(HORIZONTAL_RULE);

        // connect to one or more servers, loop until success
        connect(config.servers);

        System.out.print(HORIZONTAL_RULE);
        System.out.println(" Starting Benchmark");
        System.out.println(HORIZONTAL_RULE);

        // reset the stats after warmup
        fullStatsContext.fetchAndResetBaseline();
        periodicStatsContext.fetchAndResetBaseline();

        // print periodic statistics to the console
        benchmarkStartTS = System.currentTimeMillis();
        schedulePeriodicStats();

        // Run the benchmark loop for the requested duration
        // The throughput may be throttled depending on client configuration
        System.out.println("\nRunning benchmark...");
        final long benchmarkEndTime = System.currentTimeMillis() + (1000l * config.duration);

        while (benchmarkEndTime > System.currentTimeMillis()) {
            long[] pair = generator.getNextAppIdAndUniqueDeviceId();
            int appId = (int) pair[0];
            long nextValue = pair[1];
            long hashedValue = MurmurHash.hash64(nextValue);

            client.callProcedure(new CountCallback(),
                                 "CountDeviceEstimate",
                                 appId,
                                 hashedValue);
        }

        // cancel periodic stats printing
        timer.cancel();

        // block until all outstanding txns return
        client.drain();

        // print the summary results
        printResults();

        // close down the client connections
        client.close();
    }
1248599
private static function _getInstance()
    {
        static $i;
        if (!isset($i)) {
            $c = Kwf_Config::getValue('benchmarkClass');
            if (!class_exists($c)) {
                $c = 'Kwf_Benchmark';
            }
            $i = new $c();
        }
        return $i;
    }
910653
public void start() throws Exception {
        installShutdownHook();

        System.out.println();
        System.out.printf("Starting benchmark(s) [msgs=%d, msgsize=%d, pubs=%d, subs=%d]\n", numMsgs,
                size, numPubs, numSubs);
        System.out.printf("Current memory usage is %s / %s / %s free/total/max\n", 
                            Utils.humanBytes(Runtime.getRuntime().freeMemory()),
                            Utils.humanBytes(Runtime.getRuntime().totalMemory()),
                            Utils.humanBytes(Runtime.getRuntime().maxMemory()));
        System.out.println("Use ctrl-C to cancel.");
        System.out.println();

        if (this.numPubs > 0) {
            runTest("Pub Only", this.numPubs, 0);
            runTest("Pub/Sub", this.numPubs, this.numSubs);
        } else {
            runTest("Sub", this.numPubs, this.numSubs);
        }

        System.out.println();
        System.out.printf("Final memory usage is %s / %s / %s free/total/max\n", 
                            Utils.humanBytes(Runtime.getRuntime().freeMemory()),
                            Utils.humanBytes(Runtime.getRuntime().totalMemory()),
                            Utils.humanBytes(Runtime.getRuntime().maxMemory()));
        Runtime.getRuntime().removeShutdownHook(shutdownHook);
    }
248570
@Bench(dataProvider = "generateData")
    void benchArrayDequePush(final List<Integer> intData) {
        arrayDeque = new ArrayDeque<Integer>();
        for (final int i : intData) {
            arrayDeque.push(i);
        }
    }
1267725
public static void main(String[] args) throws Exception {
        // create a configuration from the arguments
        VoterConfig config = new VoterConfig();
        config.parse(AsyncBenchmark.class.getName(), args);

        AsyncBenchmark benchmark = new AsyncBenchmark(config);
        benchmark.runBenchmark();
    }
457147
public static void runWith(
      String[] args, Function<BenchmarkSettings, SmCodecBenchmarkState> benchmarkStateFactory) {

    BenchmarkSettings settings =
        BenchmarkSettings.from(args).durationUnit(TimeUnit.NANOSECONDS).build();

    SmCodecBenchmarkState benchmarkState = benchmarkStateFactory.apply(settings);

    benchmarkState.runForSync(
        state -> {
          BenchmarkTimer timer = state.timer("timer");
          BenchmarkMeter meter = state.meter("meter");
          ServiceMessageCodec messageCodec = state.messageCodec();
          Class<?> dataType = state.dataType();

          return i -> {
            Context timeContext = timer.time();
            ByteBuf dataBuffer = state.dataBuffer().retain();
            ByteBuf headersBuffer = state.headersBuffer().retain();
            ServiceMessage message =
                ServiceMessageCodec.decodeData(
                    messageCodec.decode(dataBuffer, headersBuffer), dataType);
            timeContext.stop();
            meter.mark();
            return message;
          };
        });
  }
926157
public static function start()
    {
        static $handle = 0;

        $start_time = microtime(true);

        self::$benchmarks[$handle] = $start_time;

        return $handle++;
    }