int main(int argc, char* argv[]) { size_t repeat = 1000000; { auto t = make_timer("Const Big String"); for (int i = 0; i < repeat; ++i) { std::string s = GetConstBigString(); if (s.empty()) { return -1; } } } { auto t = make_timer("Const Big String c_str"); for (int i = 0; i < repeat; ++i) { std::string s = GetConstBigString().c_str(); if (s.empty()) { return -1; } } } { auto t = make_timer("Big String"); for (int i = 0; i < repeat; ++i) { std::string s = GetBigString(); if (s.empty()) { return -1; } } } { auto t = make_timer("Big String c_str"); for (int i = 0; i < repeat; ++i) { std::string s = GetBigString().c_str(); if (s.empty()) { return -1; } } } return 0; }
static void ckpttimer_event_hook(DmtcpEvent_t event, DmtcpEventData_t *data) { sigset_t mask; switch (event) { case DMTCP_EVENT_INIT: { if (!doneInitialization) { get_and_save_envvars(); /* Create a timer */ timerid = make_timer(); sigemptyset(&mask); sigaddset(&mask, g_sig_num); doneInitialization = 1; } JTRACE("The plugin has been initialized."); break; } default: break; } }
void RunTasks(size_t tasks, TaskGenerator_t gen) { long firstRunTime = 0; for (size_t i = 1; i <= 16; ++i) { auto t = make_timer([&firstRunTime, i](long t) { if (i == 1) { firstRunTime = t; } std::cout << i << ' ' << (double)firstRunTime / t << std::endl; }); tbb::task_scheduler_init tsInit(i); tbb::task_group tg; for (size_t task = 0; task < tasks; ++task) { tg.run(gen()); } tg.wait(); } std::cout << std::endl; }
int main(int argc, char* argv[]) { size_t multiplier = 1; if (argc > 1) { multiplier = std::stoi(argv[1]); } size_t numbers{100000 * multiplier}; { std::vector<int> ints; auto t = make_timer("vector"); RandomOrderedFill(ints, 100, numbers); } { std::list<int> ints; auto t = make_timer("list"); RandomOrderedFill(ints, 100, numbers); } }
int SumOfBigNumbers(const Ints_t& ints, const size_t iterations, const char* message) { auto t = make_timer(message); int bigSum = 0; for (size_t iterate = 0; iterate < iterations; ++iterate) { std::for_each(ints.begin(), ints.end(), [&](int i) { if (i > BIG) { bigSum += i; } }); } return bigSum; }
int initialize_timers(configuration * connections) { int configured_ports = connections->last_slot; int i; int status = 0; for (i = 0; i <= configured_ports; i++) { if (connections->single_conn[i].timer.chk_function) { status = make_timer(&(connections->single_conn[i])); if (status) { Log(LOG_ERR, "Error creating timer for service %s", connections->single_conn[i].service_name); } } } return status; }
void RunDefaultConstructableObjectTimings(size_t objectCount, const char* objectName) { std::cout << objectName << std::endl; { // No timing, warm up the heap for (int i = 0; i < 1; ++i) { std::vector<std::shared_ptr<T>> objects; std::generate_n(std::back_inserter(objects), objectCount, [] { return std::shared_ptr<T>(new T()); }); } } { auto t = make_timer("std::shared_ptr and new : ", objectName, " ", objectCount); std::vector<std::shared_ptr<T>> objects; std::generate_n(std::back_inserter(objects), objectCount, [] { return std::shared_ptr<T>(new T()); }); } { auto t = make_timer("std::shared_ptr and make_shared : ", objectName, " ", objectCount); std::vector<std::shared_ptr<T>> objects; std::generate_n(std::back_inserter(objects), objectCount, [] { return std::make_shared<T>(); }); } { auto t = make_timer("std::unique_ptr and new : ", objectName, " ", objectCount); std::vector<std::unique_ptr<T>> objects; std::generate_n(std::back_inserter(objects), objectCount, [] { return std::unique_ptr<T>(new T()); }); } { auto t = make_timer("boost::shared_ptr and new : ", objectName, " ", objectCount); std::vector<boost::shared_ptr<T>> objects; std::generate_n(std::back_inserter(objects), objectCount, [] { return boost::shared_ptr<T>(new T()); }); } { auto t = make_timer("boost::shared_ptr and make_shared : ", objectName, " ", objectCount); std::vector<boost::shared_ptr<T>> objects; std::generate_n(std::back_inserter(objects), objectCount, [] { return boost::make_shared<T>(); }); } { auto t = make_timer("boost::intrusive_ptr : ", objectName, " ", objectCount); std::vector<boost::intrusive_ptr<T>> objects; std::generate_n(std::back_inserter(objects), objectCount, [] { return boost::intrusive_ptr<T>(new T()); }); } { auto t = make_timer(objectName, "* ", objectCount); std::vector<T*> objects; std::generate_n(std::back_inserter(objects), objectCount, [] { return new T(); }); for (auto o : objects) delete o; } std::cout << std::endl; }