int main (int argc, char *argv[]) { string data_file; string benchmark; po::options_description desc("Allowed options"); desc.add_options() ("help,h", "produce help message.") ("data,D", po::value<string>(&data_file), "data file") ("benchmark,B", po::value<string>(&benchmark), "benchmark file") ; po::variables_map vm; po::store(po::parse_command_line(argc, argv, desc), vm); po::notify(vm); FloatMatrix data(data_file); Benchmark<> bench; bench.load(benchmark); for (unsigned i = 0; i < bench.getQ(); ++i) { const float *p = data[bench.getQuery(i)]; cout << p[0]; for (int d = 1; d < data.getDim(); ++d) { cout << ' ' << p[d]; } cout << endl; } return 0; }
void test_sorter(__sorter sorter, void * const start, void * const end, size_t size, __comporator cmp) { BM.start(); (sorter)(start, end, size, cmp); cout << BM.getTime() << "\t"; EXPECT_TRUE(isSorted(start, end,size,cmp)); }
TEST_F(BenchmarkTest, it_measures_time_consuming) { Benchmark benchmark; benchmark.start(); int time_to_sleep = 1; suspend(time_to_sleep); ASSERT_TRUE(time_to_sleep <= benchmark.end()); }
/** \brief Główna funkcja programu * * Pozwala na zmierzenie czasu dla poszczególnych implementacji tablicy asocjacyjnej na różnych strukturach danych. */ int main(int argc, char **argv) { srand(time(NULL)); if (argc < 4 ) { cerr << "Zbyt mala ilosc argumentow." << endl; return 0; } Benchmark timeCount; string whichType=argv[1]; sType make; if (whichType == "aarray") make = aarray; else if (whichType == "hash") make = hash; else if (whichType == "tree") make = tree; else { cerr << "Wybrano nieprawidłową strukturę." << endl; return 0;} int problemSize = atoi(argv[2]); int noIterations = atoi(argv[3]); double time = timeCount.benchmark(noIterations, make, problemSize); cout << problemSize << "," << noIterations << "," << time << endl; }
int main(const int argc, const char *argv[]) { using namespace Slic3r; using std::cout; using std::endl; if(argc < 2) { cout << USAGE_STR << endl; return EXIT_SUCCESS; } TriangleMesh model; Benchmark bench; model.ReadSTLFile(argv[1]); model.align_to_origin(); ExPolygons ground_slice; TriangleMesh basepool; sla::base_plate(model, ground_slice, 0.1f); bench.start(); sla::create_base_pool(ground_slice, basepool); bench.stop(); cout << "Base pool creation time: " << std::setprecision(10) << bench.getElapsedSec() << " seconds." << endl; basepool.write_ascii("out.stl"); return EXIT_SUCCESS; }
void BenchWidget::paintEvent(QPaintEvent *) { if (m_done) return; QPainter p(this); m_benchmark->begin(&p, 100); PaintingRectAdjuster adjuster; adjuster.setNewBenchmark(m_benchmark); adjuster.reset(rect()); for (int i = 0; i < 100; ++i) m_benchmark->draw(&p, adjuster.newPaintingRect(), i); m_benchmark->end(&p); ++m_iteration; uint currentElapsed = timer.isNull() ? 0 : timer.elapsed(); timer.restart(); m_total += currentElapsed; // warm up for at most 5 iterations or half a second if (m_iteration >= 5 || m_total >= 500) { iterationTimes << currentElapsed; if (iterationTimes.size() >= 5) { qreal mean = 0; qreal stddev = 0; uint min = INT_MAX; for (int i = 0; i < iterationTimes.size(); ++i) { mean += iterationTimes.at(i); min = qMin(min, iterationTimes.at(i)); } mean /= qreal(iterationTimes.size()); for (int i = 0; i < iterationTimes.size(); ++i) { qreal delta = iterationTimes.at(i) - mean; stddev += delta * delta; } stddev = qSqrt(stddev / iterationTimes.size()); stddev = 100 * stddev / mean; // do 50 iterations, break earlier if we spend more than 5 seconds or have a low std deviation after 2 seconds if (iterationTimes.size() >= 50 || m_total >= 5000 || (m_total >= 2000 && stddev < 4)) { m_result = min; m_done = true; return; } } } }
TEST(Sorting, CountSort) { int size = _1000; int* array = craeteRandomArray(size); BM.start(); countSort(array, size, size); cout << "[ TIME ] 100000 => " << BM.getTime() << endl; EXPECT_TRUE(isSorted(array, size)); free(array); }
int main(const int argc, const char *argv[]) { using namespace Slic3r; using std::cout; using std::endl; if(argc < 2) { cout << USAGE_STR << endl; return EXIT_SUCCESS; } TriangleMesh model; Benchmark bench; model.ReadSTLFile(argv[1]); model.align_to_origin(); ExPolygons ground_slice; sla::Contour3D mesh; // TriangleMesh basepool; sla::base_plate(model, ground_slice, 0.1f); if(ground_slice.empty()) return EXIT_FAILURE; ExPolygon bottom_plate = ground_slice.front(); ExPolygon top_plate = bottom_plate; sla::offset(top_plate, coord_t(3.0/SCALING_FACTOR)); sla::offset(bottom_plate, coord_t(1.0/SCALING_FACTOR)); bench.start(); Polygons top_plate_triangles, bottom_plate_triangles; top_plate.triangulate_p2t(&top_plate_triangles); bottom_plate.triangulate_p2t(&bottom_plate_triangles); auto top_plate_mesh = sla::convert(top_plate_triangles, coord_t(3.0/SCALING_FACTOR), false); auto bottom_plate_mesh = sla::convert(bottom_plate_triangles, 0, true); mesh.merge(bottom_plate_mesh); mesh.merge(top_plate_mesh); sla::Contour3D w = sla::walls(bottom_plate.contour, top_plate.contour, 0, 3, 2.0, [](){}); mesh.merge(w); // sla::create_base_pool(ground_slice, basepool); bench.stop(); cout << "Base pool creation time: " << std::setprecision(10) << bench.getElapsedSec() << " seconds." << endl; // basepool.write_ascii("out.stl"); std::fstream outstream("out.obj", std::fstream::out); mesh.to_obj(outstream); return EXIT_SUCCESS; }
Benchmark* next() { Benchmark* bench = nullptr; // skips non matching benches while ((bench = this->innerNext()) && (SkCommandLineFlags::ShouldSkip(FLAGS_match, bench->getUniqueName()) || !bench->isSuitableFor(Benchmark::kGPU_Backend))) { delete bench; } return bench; }
void perform_test_trivial() { Benchmark s; typedef ParserResultElement<Benchmark> Parser; Parser p(s); { const std::string test = "bench123"; OKLIB_TESTTRIVIAL_RETHROW(::OKlib::Parser::Test_ParsingString<Parser>(p, test, ::OKlib::Parser::match_full)); if(s.name() != test) OKLIB_THROW("Resulting name is " + s.name() + ", and not " + test); } }
TEST_F(PerformanceTest, DISABLED_test_performance) { DiskHammalFactory factory(GBYTES11FILE); OutputWriter writer(GBYTESRESULT); JobConfiguration configuration(1, 150 * 1024 * 1024, 10, 20); JobClient client(configuration, factory, writer); SimpleWordMapper mapper; Benchmark benchmark; benchmark.start(); client.run_job(mapper); std::cout << "Elapsed time in second:" << benchmark.end() << std::endl; }
double read(const char * filename, std::streampos size, int n_files, int blocksize) { if (debug) printf("\n%d files: ", n_files); FILE * files[n_files]; // Open files, and set pos for (int i = 0; i<n_files; ++i) { files[i] = fopen ( filename, "rb" ); long int pos = (size/n_files)*i; fseek ( files[i], pos, SEEK_SET ); if (debug) printf("%lld, ", (unsigned long long) pos); } if (debug) printf("\n"); // Read size/n_files bytes from all files Benchmark t; t.start(); uint32_t * buffer = (uint32_t *) malloc(blocksize); // Every slice is 250' / number of files big for (uint32_t i=0; i<(size/n_files); i+=blocksize) { // should be unrolled? for (int j = 0; j<n_files; ++j) { // size_t res = fread(buffer, 1, blocksize, files[j] ); /* for (uint32_t z=0; z<blocksize/sizeof(int); ++z) { if (buffer[z] == 0) printf("Read first byte\n"); if (buffer[z] == 249999999) printf("Read last byte\n"); // fprintf(stderr, "Reading %d \n", buffer[z]); } //*/ } } t.stop(); // Close all files free(buffer); for (int i = 0; i<n_files; ++i) fclose(files[i]); return t.getSecs(); }
int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); Benchmark benchmark; for (int i = 0; i < 5; ++i) { benchmark.test(); } return a.exec(); }
int main(int argc, char** argv) { ArgParser args(argc, argv); if (!args.isSet("i")) usage(argv); const std::string algo = args.get<std::string>("a", "pairwise"), indexfn = args.get<std::string>("i"), queryfn = args.get<std::string>("q", "queries.txt"); const uint32_t threshold = args.get<uint32_t>("t", 3); Timer timer; // load queries std::vector<std::vector<uint32_t>> queries; loadQueries(queries, queryfn); std::cout << queries.size() << " queries loaded in " << timer.getAndReset() << "s" << std::endl; // load index Index* index = loadIndex(algo, indexfn); if (index == nullptr) { usage(argv); } std::cout << "Loaded index in " << timer.getAndReset() << "s" << std::endl; // create benchmark object Benchmark *benchmark = createBenchmark(algo, threshold); benchmark->setIndex(index); std::cout << "Querying index with " << queries.size() << " queries..." << std::endl; timer.reset(); // Query! for (const std::vector<uint32_t> &query : queries) { benchmark->query(query); } double queryDuration = timer.get(); std::cout << "Queried index in " << queryDuration << "s" << std::endl; std::cout << "RESULT" << " algo=" << algo << " index=" << indexfn << " queries=" << queryfn << " numQueries=" << queries.size() << " queryDuration=" << queryDuration << " msPerQuery=" << queryDuration * 1000 / queries.size() // TODO max/min query time << std::endl; }
void Benchmark::close(bool print) { if (current == NULL) throw std::runtime_error("No active benchmark to close"); Benchmark * toClose = current; #ifndef WIN32 toClose->closingTime = steady_clock::now(); #endif current = toClose->father; if (print) toClose->print(); // Suppress Benchmark if the link is lost if (current == NULL) delete(toClose); }
BOOL PRE1_level1_encrypt(CurveParams ¶ms, Big &plaintext, ProxyPK_PRE1 &publicKey, ProxyCiphertext_PRE1 &ciphertext) { #ifdef BENCHMARKING gettimeofday(&gTstart, &gTz); #endif SAFESTATIC Big k; SAFESTATIC ZZn2 temp, c1, c2; SAFESTATIC ZZn2 zPlaintext; // Select a random value k \in Z*q, and compute res1 = Zpub1^k k = rand(params.q); c1 = pow(publicKey.Zpub1, k); // Compute res2 = plaintext * Z^k temp = pow(params.Z, k); //cout << "encrypt: params.Z = " << params.Z << endl; //cout << "encrypt: temp = " << temp << endl; zPlaintext.set(plaintext, 0); //cout << "encrypt: plaintext = " << zPlaintext << endl; c2 = zPlaintext * temp; //cout << "encrypt: c1 = " << c1 << endl; //cout << "encrypt: c2 = " << c2 << endl; // Set the ciphertext data structure with (c1, c2) ciphertext.set(CIPH_FIRST_LEVEL, c1, c2); #ifdef BENCHMARKING gettimeofday(&gTend, &gTz); gBenchmark.CollectTiming(LEVELONEENCTIMING, CalculateUsecs(gTstart, gTend)); #endif return true; }
BOOL PRE1_level2_encrypt(CurveParams ¶ms, Big &plaintext, ProxyPK_PRE1 &publicKey, ProxyCiphertext_PRE1 &ciphertext) { #ifdef BENCHMARKING gettimeofday(&gTstart, &gTz); #endif SAFESTATIC Big k; SAFESTATIC ECn c1; SAFESTATIC ZZn2 temp, c2; SAFESTATIC ZZn2 zPlaintext; // Select a random value k \in Z*q and compute res1 = (k * P) k = rand(params.q); c1 = k * params.P; // Compute res2 = plaintext * Zpub1^k zPlaintext.set(plaintext, 0); temp = pow(publicKey.Zpub1, k); c2 = zPlaintext * temp; // Set the ciphertext structure with (c1, c2) ciphertext.set(CIPH_SECOND_LEVEL, c1, c2); #ifdef BENCHMARKING gettimeofday(&gTend, &gTz); gBenchmark.CollectTiming(LEVELTWOENCTIMING, CalculateUsecs(gTstart, gTend)); #endif return true; }
BOOL PRE1_reencrypt(CurveParams ¶ms, ProxyCiphertext_PRE1 &origCiphertext, DelegationKey_PRE1 &delegationKey, ProxyCiphertext_PRE1 &newCiphertext) { #ifdef BENCHMARKING gettimeofday(&gTstart, &gTz); #endif SAFESTATIC ZZn2 res1; // Compute the pairing res1 = e(kP, delegation) if (ecap(origCiphertext.c1a, delegationKey, params.q, params.cube, res1) == FALSE) { // Pairing failed. Oops. PRINT_DEBUG_STRING("Re-encryption pairing failed."); return false; } // Set the result ciphertext to (res1, c2) newCiphertext.set(CIPH_REENCRYPTED, res1, origCiphertext.c2); #ifdef BENCHMARKING gettimeofday(&gTend, &gTz); gBenchmark.CollectTiming(REENCTIMING, CalculateUsecs(gTstart, gTend)); #endif return true; }
int main(int argc, const char** argv) { if(argc != 5) { std::cout << "usage : <problem_size> <input_file> <input_max_score> <output_file>" << std::endl; return EXIT_FAILURE; } Benchmark<30> bench; bench.execute<RandomSolver, BasicProgramOption>(3, argv, argv[3], "random"); bench.execute<EDDSolver, BasicProgramOption>(3, argv, argv[3], "edd"); bench.execute<MDDSolver, BasicProgramOption>(3, argv, argv[3], "mdd"); bench.save(argv[4]); return EXIT_SUCCESS; }
int main(int argc, char** argv) { int nDoms, nVars, nJoins; Benchmark b; if (argc < 3) print_usage(); else { if (strcmp(argv[1], "rand") == 0 && argc == 5) { b.generate(atoi(argv[2]), atoi(argv[3]), atoi(argv[4])); b.BenchAll(); } else if (strcmp(argv[1], "genfile") == 0 && argc == 6) { b.generate(atoi(argv[3]), atoi(argv[4]), atoi(argv[5])); b.saveToFile(argv[2]); } else if (strcmp(argv[1], "benchfile") == 0 && argc == 3) { b.loadFromFile(argv[2]); b.BenchAll(); } else { print_usage(); } } #ifdef ENABLE_CSV fclose(csv); #endif return 0; }
/** Runs a benchmark. It runs it a couple of times just to warm everything up, and then does num_trials iterations of the benchmark for time. */ void SimpleBenchmarkRunner::run(Benchmark &bench) { bench.setup(); // Warm up. bench.run_iteration(); bench.run_iteration(); bench.finish_iteration(); // okay, now for time. uint64_t start1 = nanotime(); for(int i = 0; i < mNumTrials; ++i) { bench.finish_iteration(); } uint64_t stop1 = nanotime(); uint64_t start2 = nanotime(); for(int i = 0; i < mNumTrials; ++i) { bench.run_iteration(); bench.finish_iteration(); } uint64_t stop2 = nanotime(); mTotalTime = (stop2 - start2) - (stop1 - start1); bench.cleanup(); }
void runBenchmark(size_t count, size_t docs, const Benchmark & benchmark) { for (size_t i(0); i < count; i++) { for (size_t docId(0); docId < docs; docId++) { benchmark.compute(docId); } } }
double random_read(const char * filename, std::streampos size, int blocksize) { FILE * file; file = fopen ( filename, "rb" ); if (debug) printf("\n"); // Read size/n_files bytes from all files Benchmark t; t.start(); uint32_t * buffer = (uint32_t *) malloc(blocksize); // Every slice is 250' / number of files big // for (uint32_t i=0; i<size; i+=blocksize) for (uint32_t i=0; i<=249999999; ++i) { long int pos = rand() % size; fseek ( file, pos, SEEK_SET ); // size_t res = fread(buffer, 1, blocksize, file ); /* for (uint32_t z=0; z<blocksize/sizeof(int); ++z) { if (buffer[z] == 0) printf("Read first byte\n"); if (buffer[z] == 249999999) printf("Read last byte\n"); // fprintf(stderr, "Reading %d \n", buffer[z]); } //*/ } t.stop(); // Close all files free(buffer); fclose(file); return t.getSecs(); }
int BenchmarkRunner::run() { typedef std::vector<Benchmark *>::iterator iterator; try { _options.parse(); } catch(const std::exception &ex) { std::cerr << ex.what() << std::endl; return EXIT_FAILURE; } _log.verbose(_verbose); for(iterator i = _benchmarks.begin(), e = _benchmarks.end(); i != e; ++i) { Benchmark *bench = *i; try { _log << "*** Start benchmark " << bench->name() << std::endl; bench->setup(); for(unsigned j = 0, f = _times; j != f; ++j) bench->execute(); bench->teardown(); _log.verbose(true); _log << bench->name(); bench->report(); _log << std::endl; _log.verbose(_verbose); _log << "*** End benchmark " << bench->name() << std::endl; } catch(const std::exception &ex) { _log << ex.what() << std::endl << "*** End benchmark " << bench->name() << std::endl; return EXIT_FAILURE; } } return EXIT_SUCCESS; }
BOOL PRE1_delegate(CurveParams ¶ms, ProxyPK_PRE1 &delegatee, ProxySK_PRE1 &delegator, DelegationKey_PRE1 &reskey) { #ifdef BENCHMARKING gettimeofday(&gTstart, &gTz); #endif // Compute reskey = delegator.a1 * delegatee.Ppub2 reskey = delegator.a1 * (delegatee.Ppub2); #ifdef BENCHMARKING gettimeofday(&gTend, &gTz); gBenchmark.CollectTiming(DELEGATETIMING, CalculateUsecs(gTstart, gTend)); #endif return true; }
BOOL PRE1_decrypt(CurveParams ¶ms, ProxyCiphertext_PRE1 &ciphertext, ProxySK_PRE1 &secretKey, Big &plaintext) { #ifdef BENCHMARKING gettimeofday(&gTstart, &gTz); #endif SAFESTATIC ECn del; SAFESTATIC ZZn2 temp; SAFESTATIC ZZn2 result; // Handle each type of ciphertext switch(ciphertext.type) { case CIPH_FIRST_LEVEL: // temp = c1^inv(a1) temp = pow(ciphertext.c1b, inverse(secretKey.a1, params.qsquared)); //cout << "decrypt: temp = " << temp << endl; break; case CIPH_REENCRYPTED: // temp = c1^inv(a2) temp = pow(ciphertext.c1b, inverse(secretKey.a2, params.qsquared)); break; case CIPH_SECOND_LEVEL: // temp = e(c1, a1 * P) del = secretKey.a1 * params.P; if (ecap(ciphertext.c1a, del, params.q, params.cube, temp) == FALSE) { PRINT_DEBUG_STRING("Decryption pairing failed."); return FALSE; } break; default: PRINT_DEBUG_STRING("Decryption failed: invalid ciphertext type."); break; } // Compute plaintext = c2 / temp result = ciphertext.c2 / temp; result.get(plaintext); #ifdef BENCHMARKING gettimeofday(&gTend, &gTz); gBenchmark.CollectTiming(LEVELONEDECTIMING, CalculateUsecs(gTstart, gTend)); #endif return true; }
BOOL PRE2_delegate(CurveParams ¶ms, ProxyPK_PRE2 &delegatee, ProxySK_PRE2 &delegator, DelegationKey_PRE2 &reskey) { #ifdef BENCHMARKING gettimeofday(&gTstart, &gTz); #endif // Compute reskey = delegator.a1 * delegatee.Ppub2 Big a1inv = inverse(delegator.a1, params.q); reskey = a1inv * (delegatee.Ppub2); ECn Q = delegator.a1 * params.P; ZZn2 res1; #ifdef BENCHMARKING gettimeofday(&gTend, &gTz); gBenchmark.CollectTiming(DELEGATETIMING, CalculateUsecs(gTstart, gTend)); #endif return true; }
void AdvancedBenchmarkRunner::run(Benchmark &bench) { mTrials.clear(); bench.setup(); // Warm up. bench.run_iteration(); bench.run_iteration(); bench.finish_iteration(); // okay, now for time. for(int i = 0; i < mNumTrials; ++i) { auto start = nanotime(); bench.run_iteration(); auto stop = nanotime(); bench.finish_iteration(); mTrials.push_back(stop - start); } bench.cleanup(); }
int main(int argc, char *argv[]) { globalStructuresInit(); options.parse(argc, (const char **) (argv)); //options.printAll(); if (options.help()){ cout << options.helpToString(); exit(1); } if (options.fnCfg() != ""){ cfg.loadFromFile(options.fnCfg()); }else{ cfg.loadFromFile(string(DEFAULT_CFG)); } if (! cfg.checkConfiguration()){ logWarning("Incomplete configuration."); //exit(1); } //getMove protocol if (options.getMoveMode()){ Board board; Engine* engine = new Engine(); //last three arguments should be : position game_record gamestate file string gr = argv[argc - 2]; if (options.fnRecord() != "") { logDebug("Loading from record %s.\n", options.fnRecord().c_str()); if (! board.initFromRecord(options.fnRecord().c_str(), true)){ logError("Couldn't read record from file %s.\n", options.fnRecord().c_str()); return 1; } } else if (options.fnPosition() != "" ){ logDebug("Loading from position %s.\n", options.fnPosition().c_str()); if (! board.initFromPosition(options.fnPosition().c_str())){ //logError("Couldn't read position from file %s.\n", options.fnPosition().c_str()); } logDebug("Loading from record %s.\n", options.fnRecord().c_str()); //try to read as if it's a record if (! board.initFromRecord(options.fnPosition().c_str(), true)){ logError("Couldn't read position or record from file %s.\n", options.fnPosition().c_str()); return 1; } } //cerr << "=====" << endl; //cerr << board.toString(); engine->doSearch(&board); cout << engine->getBestMove() << endl; //cerr << engine->getStats(); //cerr << engine->getAdditionalInfo(); return 0; } //aei protocol; Aei* aei; if (options.localMode()){ //use extended aei command set aei = new Aei(AC_EXT); } else { aei = new Aei(); } if (options.benchmarkMode()){ Benchmark benchmark; benchmark.benchmarkAll(); return 0; } if (options.fnAeiInit() != "") aei->initFromFile(options.fnAeiInit()); aei->runLoop(); return 0; }
void OpticMedal::pushNotify(std::pair<int, int> dimensions) { Benchmark timer; timer.start(); sliders.emplace_back(std::make_tuple(slideAnimation, AnimationState(), timer, dimensions)); }