diff options
author | Loek Le Blansch <loek@pipeframe.xyz> | 2024-09-11 15:07:22 +0200 |
---|---|---|
committer | Loek Le Blansch <loek@pipeframe.xyz> | 2024-09-11 15:07:22 +0200 |
commit | faccce92caa85e1466e30a1284119b1a8a666fa3 (patch) | |
tree | 03b5fe155cfcb112e1b44f1bf56fe1b506a8b41c /mwe/profiling/lib/lib.cpp | |
parent | 83568a442d494078a662276969a4ed9b789dc0c7 (diff) |
add profiling pocpoc/profiling
Diffstat (limited to 'mwe/profiling/lib/lib.cpp')
-rw-r--r-- | mwe/profiling/lib/lib.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/mwe/profiling/lib/lib.cpp b/mwe/profiling/lib/lib.cpp new file mode 100644 index 0000000..9ea8f26 --- /dev/null +++ b/mwe/profiling/lib/lib.cpp @@ -0,0 +1,26 @@ +#include <chrono> +#include <thread> +#include <random> + +#include "lib.h" + +// yeah this is bad, boo hoo +using namespace std; +using std::this_thread::sleep_for; +using std::chrono::milliseconds; + +random_device dev; +mt19937 rng(dev()); +uniform_int_distribution<mt19937::result_type> random_dist(1, 50); + +static void random_slow() { + int delay = random_dist(rng); + sleep_for(milliseconds(delay)); +} + +int recursive(int rem) { + if (rem <= 0) return 0; + random_slow(); + return recursive(rem - 1) + recursive(rem - 2); +} + |