error_ut.cpp 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #include "../pg_compat.h"
  2. #include <library/cpp/testing/unittest/registar.h>
  3. extern "C" {
  4. #include <yql/essentials/parser/pg_wrapper/postgresql/src/include/postgres.h>
  5. #include <yql/essentials/parser/pg_wrapper/postgresql/src/include/utils/elog.h>
  6. }
  7. #include <util/datetime/cputimer.h>
  8. #if defined(NDEBUG) && !defined(_san_enabled_)
  9. constexpr ui32 IterationsCount = 1000000000;
  10. #else
  11. constexpr ui32 IterationsCount = 100000000;
  12. #endif
  13. Y_UNIT_TEST_SUITE(TErrorTests) {
  14. Y_UNIT_TEST(TestPgTry) {
  15. Cout << "begin...\n";
  16. TSimpleTimer timer;
  17. volatile ui32 x = 0;
  18. for (ui32 i = 0; i < IterationsCount; ++i) {
  19. PG_TRY();
  20. {
  21. x += 1;
  22. }
  23. PG_CATCH();
  24. {
  25. }
  26. PG_END_TRY();
  27. }
  28. Cout << "done, elapsed: " << timer.Get() << "\n";
  29. }
  30. Y_UNIT_TEST(TestCppTry) {
  31. Cout << "begin...\n";
  32. TSimpleTimer timer;
  33. volatile ui32 x = 0;
  34. for (ui32 i = 0; i < IterationsCount; ++i) {
  35. try {
  36. x += 1;
  37. } catch (...) {
  38. }
  39. }
  40. Cout << "done, elapsed: " << timer.Get() << "\n";
  41. }
  42. }