test/cpv_local/util/rand.cpp
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | // competitive-verifier: STANDALONE | ||
| 2 | |||
| 3 | #include "../../../src/util/func_fp/lib.hpp" | ||
| 4 | #include "../../../src/util/rand/lib.hpp" | ||
| 5 | #include "../base.hpp" | ||
| 6 | |||
| 7 | using namespace tifa_libs; | ||
| 8 | template <class T> | ||
| 9 | 12 | void test() { | |
| 10 | using res_t = std::conditional_t<sizeof(T) <= 4, u32, u64>; | ||
| 11 | 12 | res_t seed = (res_t)std::chrono::duration_cast<std::chrono::nanoseconds>(std::chrono::high_resolution_clock::now().time_since_epoch()).count(); | |
| 12 | 12 | rand_gen<T> g1; | |
| 13 |
12/24void test<char>():
✓ Branch 1 taken 1 time.
✗ Branch 2 not taken.
void test<double>():
✓ Branch 1 taken 1 time.
✗ Branch 2 not taken.
void test<float>():
✓ Branch 1 taken 1 time.
✗ Branch 2 not taken.
void test<int>():
✓ Branch 1 taken 1 time.
✗ Branch 2 not taken.
void test<long double>():
✓ Branch 1 taken 1 time.
✗ Branch 2 not taken.
void test<long>():
✓ Branch 1 taken 1 time.
✗ Branch 2 not taken.
void test<short>():
✓ Branch 1 taken 1 time.
✗ Branch 2 not taken.
void test<signed char>():
✓ Branch 1 taken 1 time.
✗ Branch 2 not taken.
void test<unsigned char>():
✓ Branch 1 taken 1 time.
✗ Branch 2 not taken.
void test<unsigned int>():
✓ Branch 1 taken 1 time.
✗ Branch 2 not taken.
void test<unsigned long>():
✓ Branch 1 taken 1 time.
✗ Branch 2 not taken.
void test<unsigned short>():
✓ Branch 1 taken 1 time.
✗ Branch 2 not taken.
|
12 | std::conditional_t<std::is_same_v<res_t, u32>, std::mt19937, std::mt19937_64> g2; |
| 14 | 12 | g1.seed(seed); | |
| 15 |
12/24void test<char>():
✓ Branch 1 taken 1 time.
✗ Branch 2 not taken.
void test<double>():
✓ Branch 1 taken 1 time.
✗ Branch 2 not taken.
void test<float>():
✓ Branch 1 taken 1 time.
✗ Branch 2 not taken.
void test<int>():
✓ Branch 1 taken 1 time.
✗ Branch 2 not taken.
void test<long double>():
✓ Branch 1 taken 1 time.
✗ Branch 2 not taken.
void test<long>():
✓ Branch 1 taken 1 time.
✗ Branch 2 not taken.
void test<short>():
✓ Branch 1 taken 1 time.
✗ Branch 2 not taken.
void test<signed char>():
✓ Branch 1 taken 1 time.
✗ Branch 2 not taken.
void test<unsigned char>():
✓ Branch 1 taken 1 time.
✗ Branch 2 not taken.
void test<unsigned int>():
✓ Branch 1 taken 1 time.
✗ Branch 2 not taken.
void test<unsigned long>():
✓ Branch 1 taken 1 time.
✗ Branch 2 not taken.
void test<unsigned short>():
✓ Branch 1 taken 1 time.
✗ Branch 2 not taken.
|
12 | g2.seed(seed); |
| 16 | 12 | const u32 N = 5'000'000; | |
| 17 | 12 | T a = std::numeric_limits<T>::min() / 3, b = std::numeric_limits<T>::max() / 3; | |
| 18 | 12 | g1.range(a, b); | |
| 19 |
12/24void test<char>():
✓ Branch 1 taken 1 time.
✗ Branch 2 not taken.
void test<double>():
✓ Branch 1 taken 1 time.
✗ Branch 2 not taken.
void test<float>():
✓ Branch 1 taken 1 time.
✗ Branch 2 not taken.
void test<int>():
✓ Branch 1 taken 1 time.
✗ Branch 2 not taken.
void test<long double>():
✓ Branch 1 taken 1 time.
✗ Branch 2 not taken.
void test<long>():
✓ Branch 1 taken 1 time.
✗ Branch 2 not taken.
void test<short>():
✓ Branch 1 taken 1 time.
✗ Branch 2 not taken.
void test<signed char>():
✓ Branch 1 taken 1 time.
✗ Branch 2 not taken.
void test<unsigned char>():
✓ Branch 1 taken 1 time.
✗ Branch 2 not taken.
void test<unsigned int>():
✓ Branch 1 taken 1 time.
✗ Branch 2 not taken.
void test<unsigned long>():
✓ Branch 1 taken 1 time.
✗ Branch 2 not taken.
void test<unsigned short>():
✓ Branch 1 taken 1 time.
✗ Branch 2 not taken.
|
12 | std::conditional_t<std::is_integral_v<T>, std::uniform_int_distribution<T>, std::uniform_real_distribution<T>> u(a, b); |
| 20 |
24/24void test<char>():
✓ Branch 0 taken 5000000 times.
✓ Branch 1 taken 1 time.
void test<double>():
✓ Branch 0 taken 5000000 times.
✓ Branch 1 taken 1 time.
void test<float>():
✓ Branch 0 taken 5000000 times.
✓ Branch 1 taken 1 time.
void test<int>():
✓ Branch 0 taken 5000000 times.
✓ Branch 1 taken 1 time.
void test<long double>():
✓ Branch 0 taken 5000000 times.
✓ Branch 1 taken 1 time.
void test<long>():
✓ Branch 0 taken 5000000 times.
✓ Branch 1 taken 1 time.
void test<short>():
✓ Branch 0 taken 5000000 times.
✓ Branch 1 taken 1 time.
void test<signed char>():
✓ Branch 0 taken 5000000 times.
✓ Branch 1 taken 1 time.
void test<unsigned char>():
✓ Branch 0 taken 5000000 times.
✓ Branch 1 taken 1 time.
void test<unsigned int>():
✓ Branch 0 taken 5000000 times.
✓ Branch 1 taken 1 time.
void test<unsigned long>():
✓ Branch 0 taken 5000000 times.
✓ Branch 1 taken 1 time.
void test<unsigned short>():
✓ Branch 0 taken 5000000 times.
✓ Branch 1 taken 1 time.
|
60000012 | flt_ (u32, i, 0, N) { |
| 21 | #pragma GCC diagnostic ignored "-Wconversion" | ||
| 22 |
12/24void test<char>():
✓ Branch 2 taken 5000000 times.
✗ Branch 3 not taken.
void test<double>():
✓ Branch 2 taken 5000000 times.
✗ Branch 3 not taken.
void test<float>():
✓ Branch 2 taken 5000000 times.
✗ Branch 3 not taken.
void test<int>():
✓ Branch 2 taken 5000000 times.
✗ Branch 3 not taken.
void test<long double>():
✓ Branch 2 taken 5000000 times.
✗ Branch 3 not taken.
void test<long>():
✓ Branch 2 taken 5000000 times.
✗ Branch 3 not taken.
void test<short>():
✓ Branch 2 taken 5000000 times.
✗ Branch 3 not taken.
void test<signed char>():
✓ Branch 2 taken 5000000 times.
✗ Branch 3 not taken.
void test<unsigned char>():
✓ Branch 2 taken 5000000 times.
✗ Branch 3 not taken.
void test<unsigned int>():
✓ Branch 2 taken 5000000 times.
✗ Branch 3 not taken.
void test<unsigned long>():
✓ Branch 2 taken 5000000 times.
✗ Branch 3 not taken.
void test<unsigned short>():
✓ Branch 2 taken 5000000 times.
✗ Branch 3 not taken.
|
60000000 | res_t x = g1.next(), y = g2(); |
| 23 | #pragma GCC diagnostic warning "-Wconversion" | ||
| 24 |
36/72void test<char>():
✓ Branch 1 taken 5000000 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 5000000 times.
✗ Branch 5 not taken.
✓ Branch 10 taken 5000000 times.
✗ Branch 11 not taken.
void test<double>():
✓ Branch 1 taken 5000000 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 5000000 times.
✗ Branch 5 not taken.
✓ Branch 10 taken 5000000 times.
✗ Branch 11 not taken.
void test<float>():
✓ Branch 1 taken 5000000 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 5000000 times.
✗ Branch 5 not taken.
✓ Branch 10 taken 5000000 times.
✗ Branch 11 not taken.
void test<int>():
✓ Branch 1 taken 5000000 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 5000000 times.
✗ Branch 5 not taken.
✓ Branch 10 taken 5000000 times.
✗ Branch 11 not taken.
void test<long double>():
✓ Branch 1 taken 5000000 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 5000000 times.
✗ Branch 5 not taken.
✓ Branch 10 taken 5000000 times.
✗ Branch 11 not taken.
void test<long>():
✓ Branch 1 taken 5000000 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 5000000 times.
✗ Branch 5 not taken.
✓ Branch 10 taken 5000000 times.
✗ Branch 11 not taken.
void test<short>():
✓ Branch 1 taken 5000000 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 5000000 times.
✗ Branch 5 not taken.
✓ Branch 10 taken 5000000 times.
✗ Branch 11 not taken.
void test<signed char>():
✓ Branch 1 taken 5000000 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 5000000 times.
✗ Branch 5 not taken.
✓ Branch 10 taken 5000000 times.
✗ Branch 11 not taken.
void test<unsigned char>():
✓ Branch 1 taken 5000000 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 5000000 times.
✗ Branch 5 not taken.
✓ Branch 10 taken 5000000 times.
✗ Branch 11 not taken.
void test<unsigned int>():
✓ Branch 1 taken 5000000 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 5000000 times.
✗ Branch 5 not taken.
✓ Branch 10 taken 5000000 times.
✗ Branch 11 not taken.
void test<unsigned long>():
✓ Branch 1 taken 5000000 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 5000000 times.
✗ Branch 5 not taken.
✓ Branch 10 taken 5000000 times.
✗ Branch 11 not taken.
void test<unsigned short>():
✓ Branch 1 taken 5000000 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 5000000 times.
✗ Branch 5 not taken.
✓ Branch 10 taken 5000000 times.
✗ Branch 11 not taken.
|
60000000 | check(x, y, check_param(seed), check_param(i)); |
| 25 | } | ||
| 26 | 12 | int cnt_eq = 0; | |
| 27 |
24/24void test<char>():
✓ Branch 0 taken 5000000 times.
✓ Branch 1 taken 1 time.
void test<double>():
✓ Branch 0 taken 5000000 times.
✓ Branch 1 taken 1 time.
void test<float>():
✓ Branch 0 taken 5000000 times.
✓ Branch 1 taken 1 time.
void test<int>():
✓ Branch 0 taken 5000000 times.
✓ Branch 1 taken 1 time.
void test<long double>():
✓ Branch 0 taken 5000000 times.
✓ Branch 1 taken 1 time.
void test<long>():
✓ Branch 0 taken 5000000 times.
✓ Branch 1 taken 1 time.
void test<short>():
✓ Branch 0 taken 5000000 times.
✓ Branch 1 taken 1 time.
void test<signed char>():
✓ Branch 0 taken 5000000 times.
✓ Branch 1 taken 1 time.
void test<unsigned char>():
✓ Branch 0 taken 5000000 times.
✓ Branch 1 taken 1 time.
void test<unsigned int>():
✓ Branch 0 taken 5000000 times.
✓ Branch 1 taken 1 time.
void test<unsigned long>():
✓ Branch 0 taken 5000000 times.
✓ Branch 1 taken 1 time.
void test<unsigned short>():
✓ Branch 0 taken 5000000 times.
✓ Branch 1 taken 1 time.
|
60000012 | flt_ (u32, i, 0, N) { |
| 28 |
12/24void test<char>():
✓ Branch 2 taken 5000000 times.
✗ Branch 3 not taken.
void test<double>():
✓ Branch 2 taken 5000000 times.
✗ Branch 3 not taken.
void test<float>():
✓ Branch 2 taken 5000000 times.
✗ Branch 3 not taken.
void test<int>():
✓ Branch 2 taken 5000000 times.
✗ Branch 3 not taken.
void test<long double>():
✓ Branch 2 taken 5000000 times.
✗ Branch 3 not taken.
void test<long>():
✓ Branch 2 taken 5000000 times.
✗ Branch 3 not taken.
void test<short>():
✓ Branch 2 taken 5000000 times.
✗ Branch 3 not taken.
void test<signed char>():
✓ Branch 2 taken 5000000 times.
✗ Branch 3 not taken.
void test<unsigned char>():
✓ Branch 2 taken 5000000 times.
✗ Branch 3 not taken.
void test<unsigned int>():
✓ Branch 2 taken 5000000 times.
✗ Branch 3 not taken.
void test<unsigned long>():
✓ Branch 2 taken 5000000 times.
✗ Branch 3 not taken.
void test<unsigned short>():
✓ Branch 2 taken 5000000 times.
✗ Branch 3 not taken.
|
60000000 | T x2 = g1(), y2 = u(g2); |
| 29 | 60000000 | cnt_eq += is_eq(x2, y2); | |
| 30 |
72/120void test<char>():
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 4999936 times.
✓ Branch 3 taken 64 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 64 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 64 times.
✗ Branch 10 not taken.
✓ Branch 12 taken 64 times.
✗ Branch 13 not taken.
void test<double>():
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 4999936 times.
✓ Branch 3 taken 64 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 64 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 64 times.
✗ Branch 10 not taken.
✓ Branch 12 taken 64 times.
✗ Branch 13 not taken.
void test<float>():
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 4999936 times.
✓ Branch 3 taken 64 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 64 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 64 times.
✗ Branch 10 not taken.
✓ Branch 12 taken 64 times.
✗ Branch 13 not taken.
void test<int>():
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 4999936 times.
✓ Branch 3 taken 64 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 64 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 64 times.
✗ Branch 10 not taken.
✓ Branch 12 taken 64 times.
✗ Branch 13 not taken.
void test<long double>():
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 4999936 times.
✓ Branch 3 taken 64 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 64 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 64 times.
✗ Branch 10 not taken.
✓ Branch 12 taken 64 times.
✗ Branch 13 not taken.
void test<long>():
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 4999936 times.
✓ Branch 3 taken 64 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 64 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 64 times.
✗ Branch 10 not taken.
✓ Branch 12 taken 64 times.
✗ Branch 13 not taken.
void test<short>():
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 4999936 times.
✓ Branch 3 taken 64 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 64 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 64 times.
✗ Branch 10 not taken.
✓ Branch 12 taken 64 times.
✗ Branch 13 not taken.
void test<signed char>():
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 4999936 times.
✓ Branch 3 taken 64 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 64 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 64 times.
✗ Branch 10 not taken.
✓ Branch 12 taken 64 times.
✗ Branch 13 not taken.
void test<unsigned char>():
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 4999936 times.
✓ Branch 3 taken 64 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 64 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 64 times.
✗ Branch 10 not taken.
✓ Branch 12 taken 64 times.
✗ Branch 13 not taken.
void test<unsigned int>():
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 4999936 times.
✓ Branch 3 taken 64 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 64 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 64 times.
✗ Branch 10 not taken.
✓ Branch 12 taken 64 times.
✗ Branch 13 not taken.
void test<unsigned long>():
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 4999936 times.
✓ Branch 3 taken 64 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 64 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 64 times.
✗ Branch 10 not taken.
✓ Branch 12 taken 64 times.
✗ Branch 13 not taken.
void test<unsigned short>():
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 4999936 times.
✓ Branch 3 taken 64 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 64 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 64 times.
✗ Branch 10 not taken.
✓ Branch 12 taken 64 times.
✗ Branch 13 not taken.
|
60000000 | if (i < 64) std::cerr << x2 << ' ' << y2 << '\n'; |
| 31 | }; | ||
| 32 |
24/48void test<char>():
✓ Branch 1 taken 1 time.
✗ Branch 2 not taken.
✓ Branch 6 taken 1 time.
✗ Branch 7 not taken.
void test<double>():
✓ Branch 1 taken 1 time.
✗ Branch 2 not taken.
✓ Branch 6 taken 1 time.
✗ Branch 7 not taken.
void test<float>():
✓ Branch 1 taken 1 time.
✗ Branch 2 not taken.
✓ Branch 6 taken 1 time.
✗ Branch 7 not taken.
void test<int>():
✓ Branch 1 taken 1 time.
✗ Branch 2 not taken.
✓ Branch 6 taken 1 time.
✗ Branch 7 not taken.
void test<long double>():
✓ Branch 1 taken 1 time.
✗ Branch 2 not taken.
✓ Branch 6 taken 1 time.
✗ Branch 7 not taken.
void test<long>():
✓ Branch 1 taken 1 time.
✗ Branch 2 not taken.
✓ Branch 6 taken 1 time.
✗ Branch 7 not taken.
void test<short>():
✓ Branch 1 taken 1 time.
✗ Branch 2 not taken.
✓ Branch 6 taken 1 time.
✗ Branch 7 not taken.
void test<signed char>():
✓ Branch 1 taken 1 time.
✗ Branch 2 not taken.
✓ Branch 6 taken 1 time.
✗ Branch 7 not taken.
void test<unsigned char>():
✓ Branch 1 taken 1 time.
✗ Branch 2 not taken.
✓ Branch 6 taken 1 time.
✗ Branch 7 not taken.
void test<unsigned int>():
✓ Branch 1 taken 1 time.
✗ Branch 2 not taken.
✓ Branch 6 taken 1 time.
✗ Branch 7 not taken.
void test<unsigned long>():
✓ Branch 1 taken 1 time.
✗ Branch 2 not taken.
✓ Branch 6 taken 1 time.
✗ Branch 7 not taken.
void test<unsigned short>():
✓ Branch 1 taken 1 time.
✗ Branch 2 not taken.
✓ Branch 6 taken 1 time.
✗ Branch 7 not taken.
|
12 | check_bool(cnt_eq == N, check_param(cnt_eq)); |
| 33 | 12 | } | |
| 34 | |||
| 35 | 1 | int main() { | |
| 36 |
3/6✓ Branch 4 taken 1 time.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 time.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 time.
✗ Branch 11 not taken.
|
1 | timer_(test<char>()); |
| 37 |
3/6✓ Branch 4 taken 1 time.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 time.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 time.
✗ Branch 11 not taken.
|
1 | timer_(test<i8>()); |
| 38 |
3/6✓ Branch 4 taken 1 time.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 time.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 time.
✗ Branch 11 not taken.
|
1 | timer_(test<u8>()); |
| 39 |
3/6✓ Branch 4 taken 1 time.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 time.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 time.
✗ Branch 11 not taken.
|
1 | timer_(test<i16>()); |
| 40 |
3/6✓ Branch 4 taken 1 time.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 time.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 time.
✗ Branch 11 not taken.
|
1 | timer_(test<u16>()); |
| 41 |
3/6✓ Branch 4 taken 1 time.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 time.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 time.
✗ Branch 11 not taken.
|
1 | timer_(test<i32>()); |
| 42 |
3/6✓ Branch 4 taken 1 time.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 time.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 time.
✗ Branch 11 not taken.
|
1 | timer_(test<u32>()); |
| 43 |
3/6✓ Branch 4 taken 1 time.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 time.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 time.
✗ Branch 11 not taken.
|
1 | timer_(test<i64>()); |
| 44 |
3/6✓ Branch 4 taken 1 time.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 time.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 time.
✗ Branch 11 not taken.
|
1 | timer_(test<u64>()); |
| 45 |
3/6✓ Branch 4 taken 1 time.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 time.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 time.
✗ Branch 11 not taken.
|
1 | timer_(test<f32>()); |
| 46 |
3/6✓ Branch 4 taken 1 time.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 time.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 time.
✗ Branch 11 not taken.
|
1 | timer_(test<f64>()); |
| 47 |
3/6✓ Branch 4 taken 1 time.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 time.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 time.
✗ Branch 11 not taken.
|
1 | timer_(test<f128>()); |
| 48 | 1 | } | |
| 49 |