Core benchmark code.
Connect. Initialize. Run the loop. Cleanup. Print Results.

@throws Exception if anything unexpected happens.
485397
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);

        // preload keys if requested
        System.out.println();
        if (config.preload) {
            System.out.println("Preloading data store...");
            for(int i=0; i < config.poolsize; i++) {
                String keyStr = String.format(processor.KeyFormat, i);
                byte[] valArr = processor.generateForStore().getStoreValue();
                if (config.multisingleratio != 0.00) {
                    client.callProcedure(new NullCallback(),
                                         "STORER.upsert",
                                         keyStr,
                                         valArr);
                }
                client.callProcedure(new NullCallback(),
                                     "STORE.upsert",
                                     keyStr,
                                     valArr);
            }
            client.drain();
            System.out.println("Preloading complete.\n");
        }

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

        // Run the benchmark loop for the requested warmup time
        // The throughput may be throttled depending on client configuration
        System.out.println("Warming up...");
        final long warmupEndTime = System.currentTimeMillis() + (1000l * config.warmup);
        while (warmupEndTime > System.currentTimeMillis()) {
            // Decide whether to perform a GET or PUT operation
            if (rand.nextDouble() < config.getputratio) {
                // Get a key/value pair using inbuilt select procedure, asynchronously
                if (rand.nextDouble() < config.multisingleratio) {
                    client.callProcedure(new NullCallback(), "selectR", processor.generateRandomKeyForRetrieval());
                }
                else {
                    client.callProcedure(new NullCallback(), "STORE.select", processor.generateRandomKeyForRetrieval());
                }
            }
            else {
                String table = rand.nextDouble() < config.multisingleratio ? "STORER" : "STORE";
                // Put a key/value pair using inbuilt upsert procedure, asynchronously
                final PayloadProcessor.Pair pair = processor.generateForStore();
                client.callProcedure(new NullCallback(), table+".upsert", pair.Key, pair.getStoreValue());
            }
        }

        // 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()) {
            // Decide whether to perform a GET or PUT operation
            if (rand.nextDouble() < config.getputratio) {
                // Get a key/value pair using inbuilt select procedure, asynchronously
                if (rand.nextDouble() < config.multisingleratio) {
                    client.callProcedure(new GetCallback(), "selectR", processor.generateRandomKeyForRetrieval());
                }
                else {
                    client.callProcedure(new GetCallback(), "STORE.select", processor.generateRandomKeyForRetrieval());
                }
            }
            else {
                String table = rand.nextDouble() < config.multisingleratio ? "STORER" : "STORE";
                // Put a key/value pair using inbuilt upsert procedure, asynchronously
                final PayloadProcessor.Pair pair = processor.generateForStore();
                client.callProcedure(new PutCallback(pair), table+".upsert", pair.Key, pair.getStoreValue());
            }
        }

        // 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();
    }
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()
1178459
@Override
    public void run ()
    {
        try {
            _running = true;
            willStart();

            while (isRunning()) {
                try {
                    iterate();
                } catch (Exception e) {
                    handleIterateFailure(e);
                }
            }

        } catch (Throwable t) {
            log.warning("Looping thread terminated with exception.", "thread", this, t);

        } finally {
            // running needs to be false even if this exited due to a Throwable from iterate
            _running = false;
            didShutdown();
        }
    }
1281748
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);

        // initialize using synchronous call
        // Initialize the application
        System.out.println("\nPopulating Static Tables\n");
        final PreparedStatement initializeCS = client
                .prepareCall("{call Initialize(?,?)}");
        initializeCS.setInt(1, config.contestants);
        initializeCS.setString(2, CONTESTANT_NAMES_CSV);
        initializeCS.executeUpdate();

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

        // create/start the requested number of threads
        Thread[] voterThreads = new Thread[config.threads];
        for (int i = 0; i < config.threads; ++i) {
            voterThreads[i] = new Thread(new VoterThread());
            voterThreads[i].start();
        }

        // Run the benchmark loop for the requested warmup time
        System.out.println("Warming up...");
        Thread.sleep(1000l * config.warmup);

        // signal to threads to end the warmup phase
        warmupComplete.set(true);

        // 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 warmup time
        System.out.println("\nRunning benchmark...");
        Thread.sleep(1000l * config.duration);

        // stop the threads
        benchmarkComplete.set(true);

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

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

        // join on the threads
        for (Thread t : voterThreads) {
            t.join();
        }

        // print the summary results
        printResults();

        // close down the client connections
        client.close();
    }
54791
private static void usage() {
    new HelpFormatter().printHelp(String.format(
        "java -cp %s %s -type <[READ, WRITE]> -fileSize <fileSize> -iterations <iterations> "
            + "-concurrency <concurrency>",
        RuntimeConstants.ALLUXIO_JAR, MiniBenchmark.class.getCanonicalName()),
        "run a mini benchmark to write or read a file",
        OPTIONS, "", true);
  }
890827
@SuppressWarnings("InfiniteLoopStatement")
  @Override
  public void run() {
    try {
      while (true) {
        try {
          cleanUp(queue.remove());
        } catch (InterruptedException e) { /* ignore */ }
      }
    } catch (ShutDown shutDown) { /* ignore */ }
  }
1292143
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(client, config.servers);

        for (long i = 0; i < config.tuples; i++) {
            ClientResponse response = client.callProcedure("Init", i, i);
            if (response.getStatus() != ClientResponse.SUCCESS) {
                System.exit(-1);
            }
        }

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

        System.out.println("\nWarming up...");
        final long warmupEndTime = System.currentTimeMillis() + (1000l * config.warmup);
        while (warmupEndTime > System.currentTimeMillis()) {
            increment();
        }

        // reset counters before the real benchmark starts post-warmup
        incrementCount.set(0);
        lastPeriod.set(0);
        failureCount.set(0);
        lastStatsReportTS = System.currentTimeMillis();

        // print periodic statistics to the console
        benchmarkStartTS = System.currentTimeMillis();
        TimerTask statsPrinting = new TimerTask() {
            @Override
            public void run() { printStatistics(); }
        };
        Timer timer = new Timer();
        timer.scheduleAtFixedRate(statsPrinting,
                                  config.displayinterval * 1000,
                                  config.displayinterval * 1000);

        // 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()) {
            increment();
        }

        // cancel periodic stats printing
        timer.cancel();
        // block until all outstanding txns return
        client.drain();
        // close down the client connections
        client.close();
    }
501271
public Boolean call() throws Exception {
    Boolean 	result;

    try {
      result = doRun();
    }
    catch (Exception e) {
      m_Exception = e;
      throw e;
    }
    finally {
      cleanUp();
    }
    return result;
  }
1116221
public void run() {

        System.out.println(HORIZONTAL_RULE);
        System.out.println(" Getting initial database partition count");
        long partitionCount = 0;
        try {
            VoltTable results[] = client.callProcedure("@GetPartitionKeys", "integer").getResults();
            partitionCount = results[0].getRowCount();
            updatePartitionCount(partitionCount);
        } catch (IOException | ProcCallException e) {
            System.out.print(HORIZONTAL_RULE);
            System.out.println("Could not get partition information. Processing terminated. Error:" + e.getMessage());
            e.printStackTrace();
            shutdown();
            System.out.print(HORIZONTAL_RULE);
            return;
        }
        System.out.println(" Initial database partition count: " + partitionCount);
        System.out.print(HORIZONTAL_RULE);
        System.out.println(" Starting Processing");
        System.out.println(HORIZONTAL_RULE);

        // Print periodic stats/analysis to the console
        scheduler.scheduleWithFixedDelay(reporter,
                                               config.displayinterval,
                                               config.displayinterval,
                                               TimeUnit.SECONDS);

        if (!config.inline) {
            // Delete data as often as need be
            //  -- This will resubmit itself at varying rates according to insert load
            scheduler.execute(deleter);
        }

        // Start tracking changes to the maximum value after a 5 second delay to
        // let things settle a bit. Then check up to 100 times per second.
        scheduler.scheduleWithFixedDelay(maxTracker,
                                               5000,
                                               10,
                                               TimeUnit.MILLISECONDS);

        // Run the benchmark loop for the requested duration
        // The throughput may be throttled depending on client configuration
        inserter.run();

        System.out.print(HORIZONTAL_RULE);
        System.out.println(" Processing Complete");
        System.out.println(HORIZONTAL_RULE);

        shutdown();
    }
1300691
public BenchmarkResult run() {
		final BenchmarkResult res = new BenchmarkResult(conf.getListener());
		BenchmarkExecutor.initialize(conf, res);

		// instantiate methods
		final Map<Class<?>, Object> instantiatedObjs = instantiateObjects(res);

		// getting Benchmarkables
		try {
			final List<BenchmarkElement> elements = getBenchmarkElements(instantiatedObjs);

			// arranging them
			final AbstractMethodArrangement arrangement = AbstractMethodArrangement
					.getMethodArrangement(elements, conf.getArrangement());

			// getting the mapping and executing beforemethod
			final Map<Class<?>, Object> objectsToExecute = executeBeforeBenchClass(
					instantiatedObjs, res);

			// executing the bench for the arrangement
			for (final BenchmarkElement elem : arrangement) {
				// invoking gc if possible
				if (RAN.nextDouble() < conf.getGcProb()) {
					System.gc();
				}

				final BenchmarkExecutor exec = BenchmarkExecutor
						.getExecutor(elem);

				final Object obj = objectsToExecute.get(elem.getMeth()
						.getMethodToBench().getDeclaringClass());
				// check needed because of failed initialization of objects
				if (obj != null) {
					exec.executeBeforeMethods(obj);
					exec.executeBench(obj, elem.getParameter());
					exec.executeAfterMethods(obj);
				}
			}

			// cleaning up methods to benchmark
			tearDownObjectsToExecute(objectsToExecute, res);
		} catch (PerfidixMethodCheckException exc) {
			res.addException(exc);
		}
		return res;
	}
106627
public void start() throws Exception{
		if(cleanupDirectory){
			CleanUp.start(conf);
		}
		IDatabaseDev db = (IDatabaseDev) em.getDB();//TODO make sure DB platform can be used for development
		ModelDefinitionProvider provider = new ModelDefinitionProvider(db, conf.dbUser, null, conf.includeSchema);
		ModelDef[] origModelList = provider.getTableDefinitions();
		
		new ModelMetaDataGenerator().start(origModelList, conf);
		//TODO: proper support for explicit ModelDefinitions
		ModelDef[] withExplecitList = overrideModelDefFromExplicit(origModelList, explicitMeta);
		ModelDef[] modelList = correctModelList(withExplecitList);
		
		new DAOClassGenerator().start(modelList, conf, true, false);
		new BeanGenerator().start(modelList, conf);
		new MapperGenerator().start(modelList, conf);

		ModelDef[] modelListOwned = setModelOwners(modelList, tableGroups);
		ModelDef[] modelListChilded = setDirectChildren(modelListOwned);

		new ColumnNameGenerator().start(modelListChilded, conf);
		new TableNameGenerator().start(modelListChilded, conf);
		new SchemaTableGenerator().start(modelListChilded, conf);
		new TableColumnGenerator().start(modelListChilded, conf);
		//new ModelMetaDataGenerator().start(modelListChilded, conf);
		
		new DAOInstanceFactoryGenerator().start(modelListChilded, conf);
		new ModelToDAOConversionGenerator().start(modelListChilded, conf);
	}
295145
protected void initOutputs() throws Exception {
		this.chainedTasks = new ArrayList<ChainedDriver<?, ?>>();
		this.eventualOutputs = new ArrayList<RecordWriter<?>>();

		ClassLoader userCodeClassLoader = getUserCodeClassLoader();

		this.accumulatorMap = getEnvironment().getAccumulatorRegistry().getUserMap();

		this.output = initOutputs(this, userCodeClassLoader, this.config, this.chainedTasks, this.eventualOutputs,
				this.getExecutionConfig(), this.accumulatorMap);
	}
936546
public void run() {
        // Reset the stats managed by the client.
        periodicStatsContext.fetchAndResetBaseline();

        // Run in a loop for config.duration seconds.
        final long benchmarkEndTime = app.startTS + (1000l * app.config.duration);
        while (benchmarkEndTime > System.currentTimeMillis()) {

            // GENERATE A RANDOM ROW

            // unique identifier and partition key
            String uuid = UUID.randomUUID().toString();

            // millisecond timestamp
            Date now = new Date();

            // for some odd reason, this will give LONG_MAX if the
            // computed value is > LONG_MAX.
            long val = (long) (rand.nextGaussian() * 1000.0);

            try {
                basicInsert(uuid, val, now);
            }
            catch (IOException e) {
                // Not being super picky about failure handling. If this
                // fails, it will show up in the client-side statistics we
                // print out in printReport().
            }
        }

        // When ready to end processing...
        try {
            // Block until all async calls have returned.
            client.drain();
            // Clean close of the client connection.
            client.close();
        }
        catch (IOException | InterruptedException e) {
            // Live dangerously and ignore this error that probably
            // won't happen at shutdown time.
        }

    }
174748
public synchronized void printResults() throws Exception {
        ClientStats stats = fullStatsContext.fetch().getStats();

        // 1. Get/Put performance results
        String display = "\n" +
                         HORIZONTAL_RULE +
                         " KV Store Results\n" +
                         HORIZONTAL_RULE +
                         "\nA total of %,d operations were posted...\n" +
                         " - GETs: %,9d Operations (%,d Misses and %,d Failures)\n" +
                         "         %,9d MB in compressed store data\n" +
                         "         %,9d MB in uncompressed application data\n" +
                         "         Network Throughput: %6.3f Gbps*\n" +
                         " - PUTs: %,9d Operations (%,d Failures)\n" +
                         "         %,9d MB in compressed store data\n" +
                         "         %,9d MB in uncompressed application data\n" +
                         "         Network Throughput: %6.3f Gbps*\n" +
                         " - Total Network Throughput: %6.3f Gbps*\n\n" +
                         "* Figure includes key & value traffic but not database protocol overhead.\n\n";

        double oneGigabit = (1024 * 1024 * 1024) / 8;
        long oneMB = (1024 * 1024);
        double getThroughput = networkGetData.get() + (successfulGets.get() * config.keysize);
               getThroughput /= (oneGigabit * config.duration);
        long totalPuts = successfulPuts.get() + failedPuts.get();
        double putThroughput = networkGetData.get() + (totalPuts * config.keysize);
               putThroughput /= (oneGigabit * config.duration);

        System.out.printf(display,
                stats.getInvocationsCompleted(),
                successfulGets.get(), missedGets.get(), failedGets.get(),
                networkGetData.get() / oneMB,
                rawGetData.get() / oneMB,
                getThroughput,
                successfulPuts.get(), failedPuts.get(),
                networkPutData.get() / oneMB,
                rawPutData.get() / oneMB,
                putThroughput,
                getThroughput + putThroughput);

        // 2. Performance statistics
        System.out.print(HORIZONTAL_RULE);
        System.out.println(" Client Workload Statistics");
        System.out.println(HORIZONTAL_RULE);

        System.out.printf("Average throughput:            %,9d txns/sec\n", stats.getTxnThroughput());
        System.out.printf("Average latency:               %,9.2f ms\n", stats.getAverageLatency());
        System.out.printf("10th percentile latency:       %,9.2f ms\n", stats.kPercentileLatencyAsDouble(.1));
        System.out.printf("25th percentile latency:       %,9.2f ms\n", stats.kPercentileLatencyAsDouble(.25));
        System.out.printf("50th percentile latency:       %,9.2f ms\n", stats.kPercentileLatencyAsDouble(.5));
        System.out.printf("75th percentile latency:       %,9.2f ms\n", stats.kPercentileLatencyAsDouble(.75));
        System.out.printf("90th percentile latency:       %,9.2f ms\n", stats.kPercentileLatencyAsDouble(.9));
        System.out.printf("95th percentile latency:       %,9.2f ms\n", stats.kPercentileLatencyAsDouble(.95));
        System.out.printf("99th percentile latency:       %,9.2f ms\n", stats.kPercentileLatencyAsDouble(.99));
        System.out.printf("99.5th percentile latency:     %,9.2f ms\n", stats.kPercentileLatencyAsDouble(.995));
        System.out.printf("99.9th percentile latency:     %,9.2f ms\n", stats.kPercentileLatencyAsDouble(.999));

        System.out.print("\n" + HORIZONTAL_RULE);
        System.out.println(" System Server Statistics");
        System.out.println(HORIZONTAL_RULE);

        System.out.printf("Reported Internal Avg Latency: %,9.2f ms\n", stats.getAverageInternalLatency());

        System.out.print("\n" + HORIZONTAL_RULE);
        System.out.println(" Latency Histogram");
        System.out.println(HORIZONTAL_RULE);
        System.out.println(stats.latencyHistoReport());

        // 3. Write stats to file if requested
        client.writeSummaryCSV(stats, config.statsfile);
    }
331690
public synchronized void printResults() throws Exception {
        printHeading("Transaction Results");

        BenchmarkCallback.printAllResults();

        ClientStats stats = fullStatsContext.fetch().getStats();

        // 3. Performance statistics
        printHeading("Client Workload Statistics");

        System.out.printf("Average throughput:            %,9d txns/sec\n", stats.getTxnThroughput());
        // cast stats.getAverateLatency from long to double
        System.out.printf("Average latency:               %,9.2f ms\n", stats.getAverageLatency());
        //System.out.printf("Average latency:               %,9d ms\n", stats.getAverageLatency());
        System.out.printf("95th percentile latency:       %,9d ms\n", stats.kPercentileLatency(.95));
        System.out.printf("99th percentile latency:       %,9d ms\n", stats.kPercentileLatency(.99));

        printHeading("System Server Statistics");

        // cast stats.getAverageInternalLatency from long to double
        System.out.printf("Reported Internal Avg Latency: %,9.2f ms\n", stats.getAverageInternalLatency());
        //System.out.printf("Reported Internal Avg Latency: %,9d ms\n", stats.getAverageInternalLatency());

        // 4. Write stats to file if requested
        client.writeSummaryCSV(stats, config.statsfile);
    }
944797
protected Boolean doRun() throws Exception{
    Point<Object>	evals;
    Evaluation 		eval;
    Classifier 		classifier;
    Performance		performance;
    boolean		completed;

    // setup
    try {
      evals = m_Generator.evaluate(m_Values);
      classifier = (Classifier) m_Generator.setup((Serializable) m_Owner.getClassifier(), evals);
    }
    catch (Exception e) {
      m_Exception = e;
      System.err.println("Failed to configure classifier!");
      e.printStackTrace();
      return false;
    }

    // evaluate
    try {
      eval = new Evaluation(m_Train);
      eval.setDiscardPredictions(canDiscardPredictions());
      if (m_Test == null) {
        if (m_Folds >= 2) {
          eval.crossValidateModel(classifier, m_Train, m_Folds, new Random(m_Owner.getSeed()));
        }
        else {
          classifier.buildClassifier(m_Train);
          eval.evaluateModel(classifier, m_Train);
        }
      }
      else {
        classifier.buildClassifier(m_Train);
        eval.evaluateModel(classifier, m_Test);
      }
      completed = true;
    }
    catch (Exception e) {
      eval = null;
      m_Exception = e;
      System.err.println("Encountered exception while evaluating classifier, skipping!");
      System.err.println("- Classifier: " + m_Owner.getCommandline(classifier));
      e.printStackTrace();
      completed = false;
    }

    // store performance
    performance = new Performance(
      m_Values,
      m_Owner.getFactory().newWrapper(eval),
      m_Evaluation,
      m_ClassLabel,
      (Classifier) m_Generator.setup((Serializable) m_Owner.getClassifier(), evals));
    m_Owner.getAlgorithm().addPerformance(performance, m_Folds);

    // log
    m_Owner.log(performance + ": cached=false");

    return completed;
  }
375290
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);

        // initialize using synchronous call
        System.out.println("\nPopulating Static Tables\n");
        client.callProcedure("Initialize", config.contestants, CONTESTANT_NAMES_CSV);

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

        // Run the benchmark loop for the requested warmup time
        // The throughput may be throttled depending on client configuration
        System.out.println("Warming up...");
        final long warmupEndTime = System.currentTimeMillis() + (1000l * config.warmup);
        while (warmupEndTime > System.currentTimeMillis()) {
            // Get the next phone call
            PhoneCallGenerator.PhoneCall call = switchboard.receive();

            // asynchronously call the "Vote" procedure
            client.callProcedure(new NullCallback(),
                                 "Vote",
                                 call.phoneNumber,
                                 call.contestantNumber,
                                 config.maxvotes);
        }

        // 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()) {
            // Get the next phone call
            PhoneCallGenerator.PhoneCall call = switchboard.receive();

            // asynchronously call the "Vote" procedure
            client.callProcedure(new VoterCallback(),
                                 "Vote",
                                 call.phoneNumber,
                                 call.contestantNumber,
                                 config.maxvotes);
        }

        // 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();
    }