// // Created by trotfunky on 06/11/2020. // #include #include #include #include "NegBin.h" int main() { std::random_device rd; std::default_random_engine gen(rd()); std::uniform_int_distribution<> distribution(0,2147483647); std::vector randoms1; std::vector randoms2; randoms1.reserve(1000000); randoms2.reserve(1000000); for (int i = 0;i<1000000;i++) { randoms1.emplace_back(longBitField(distribution(gen))); randoms2.emplace_back(longBitField(distribution(gen))); } NegBin temp; auto start = std::chrono::high_resolution_clock::now(); for (int i = 0;i<1000000;i++) { temp = randoms1.at(i) + randoms2.at(i); } auto end = std::chrono::high_resolution_clock::now(); auto total_duration = std::chrono::duration_cast(end-start); std::cout << "Total time taken for 1 000 000 iterations is :" << total_duration.count()/1000 << "µs" << std::endl; std::cout << "Time per addition is roughly : " << total_duration.count()/1000000 << "ns" << std::endl; std::vector randomsInts1; std::vector randomsInts2; randomsInts1.reserve(1000000); randomsInts2.reserve(1000000); for (int i = 0;i<1000000;i++) { randomsInts1.push_back(distribution(gen)); randomsInts2.push_back(distribution(gen)); } long tempInt; auto startInts = std::chrono::high_resolution_clock::now(); for (int i = 0;i<1000000;i++) { tempInt = randomsInts1.at(i) * randomsInts2.at(i); } auto endInts = std::chrono::high_resolution_clock::now(); auto total_int_duration = std::chrono::duration_cast(endInts-startInts); std::cout << "Total time taken for 1 000 000 iterations is :" << total_int_duration.count()/1000 << "µs" << std::endl; std::cout << "Time per addition is roughly : " << total_int_duration.count()/1000000 << "ns" << std::endl; return 0; }