online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code    Language
/****************************************************************************** Online C++ Compiler. Code, Compile, Run and Debug C++ program online. Write your code in this editor and press "Run" button to compile and execute it. *******************************************************************************/ #include <iostream> #include <random> #include <limits> #include <map> #include <chrono> #include <functional> #define TIMES 1000000 double get_time() { return std::chrono::duration<double>(std::chrono::system_clock::now().time_since_epoch()).count(); } int number(int v1, int v2) { thread_local std::default_random_engine _Generator; thread_local bool _Init = false; if (!_Init) { _Init = true; std::random_device dev; _Generator.seed(dev()); } std::uniform_int_distribution<int> distribution(v1, v2); return distribution(_Generator); } int random_drop(int min, int max) { std::random_device device; std::mt19937 generator(device()); std::uniform_int_distribution<int> distribution(min, max); return distribution(generator); } double execution_time(std::function<int(int,int)> func) { auto now = get_time(); for(int i=0; i < TIMES; i++) func(0,500); auto end = get_time(); return end - now; } int main() { std::cout << "number time : " << execution_time(number) << std::endl; std::cout << "random_drop time : " << execution_time(random_drop) << std::endl; }

Compiling Program...

Command line arguments:
Standard Input: Interactive Console Text
×

                

                

Program is not being debugged. Click "Debug" button to start program in debug mode.

#FunctionFile:Line
VariableValue
RegisterValue
ExpressionValue