aboutsummaryrefslogtreecommitdiffstats
path: root/yql/essentials/parser/pg_wrapper/ut/error_ut.cpp
blob: 1f9ade9c955be641112d3aedb7f6bdb2a8bf1e2b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include "../pg_compat.h"

#include <library/cpp/testing/unittest/registar.h>

extern "C" {
#include <yql/essentials/parser/pg_wrapper/postgresql/src/include/postgres.h>
#include <yql/essentials/parser/pg_wrapper/postgresql/src/include/utils/elog.h>
}

#include <util/datetime/cputimer.h>

#if defined(NDEBUG) && !defined(_san_enabled_)
constexpr ui32 IterationsCount = 1000000000;
#else
constexpr ui32 IterationsCount = 100000000;
#endif

Y_UNIT_TEST_SUITE(TErrorTests) {
    Y_UNIT_TEST(TestPgTry) {
        Cout << "begin...\n";
        TSimpleTimer timer;
        volatile ui32 x = 0;
        for (ui32 i = 0; i < IterationsCount; ++i) {
            PG_TRY();
            {
                x += 1;
            }
            PG_CATCH();
            {
            }
            PG_END_TRY();
        }

        Cout << "done, elapsed: " << timer.Get() << "\n";
    }

    Y_UNIT_TEST(TestCppTry) {
        Cout << "begin...\n";
        TSimpleTimer timer;
        volatile ui32 x = 0;
        for (ui32 i = 0; i < IterationsCount; ++i) {
            try {
                x += 1;
            } catch (...) {
            }
        }

        Cout << "done, elapsed: " << timer.Get() << "\n";
    }
}