From 813049a3ff85b18bc1ca6f640c7677c8bbf39414 Mon Sep 17 00:00:00 2001 From: KunoiSayami Date: Sun, 18 Jun 2023 21:26:01 +0800 Subject: feat(exp): Add more test for level Signed-off-by: KunoiSayami --- expt_0618_2.cpp | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 expt_0618_2.cpp (limited to 'expt_0618_2.cpp') diff --git a/expt_0618_2.cpp b/expt_0618_2.cpp new file mode 100644 index 0000000..4c104ad --- /dev/null +++ b/expt_0618_2.cpp @@ -0,0 +1,33 @@ +#include +#include + +constexpr size_t MAX_LEVEL = 32; + +void generateRandomLevel(std::vector &v, long run_times) { + // auto levels = new int[size]; + std::random_device randomDevice; + std::mt19937 randomEngine(randomDevice()); + std::geometric_distribution<> distribution(0.5); + for (int i = 0; i < run_times; i++) { + v[(int)std::min(MAX_LEVEL, (size_t)distribution(randomEngine))]++; + } +} + +int main(int argc, char const *argv[]) { + + auto run_times = 65536L; + + if (argc >= 2) { + run_times = strtol(argv[1], nullptr, 10); + } + + std::vector result(MAX_LEVEL + 3); + generateRandomLevel(result, run_times); + + for (int i = 0; i < 32; i++) { + if (!result[i]) { + continue; + } + printf("%d: %d\n", i, result[i]); + } +} \ No newline at end of file -- cgit v1.3.1