aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkungasc <kungasc@yandex-team.com>2023-05-25 15:11:20 +0300
committerkungasc <kungasc@yandex-team.com>2023-05-25 15:11:20 +0300
commit36161a0673e3c898b48819ba206fa38409b896f5 (patch)
treed98bcdc33efd57c970f4a4b367cb49659b874cb9
parent1fdca17f924b7862c94f670192a3b57ac27ec215 (diff)
downloadydb-36161a0673e3c898b48819ba206fa38409b896f5.tar.gz
Add precharge benchmark
-rw-r--r--contrib/libs/CMakeLists.darwin-x86_64.txt1
-rw-r--r--contrib/libs/CMakeLists.linux-aarch64.txt1
-rw-r--r--contrib/libs/CMakeLists.linux-x86_64.txt1
-rw-r--r--contrib/libs/CMakeLists.windows-x86_64.txt1
-rw-r--r--contrib/libs/benchmark/CMakeLists.darwin-x86_64.txt50
-rw-r--r--contrib/libs/benchmark/CMakeLists.linux-aarch64.txt51
-rw-r--r--contrib/libs/benchmark/CMakeLists.linux-x86_64.txt51
-rw-r--r--contrib/libs/benchmark/CMakeLists.txt17
-rw-r--r--contrib/libs/benchmark/CMakeLists.windows-x86_64.txt50
-rw-r--r--contrib/libs/benchmark/test/benchmark_gtest.cc169
-rw-r--r--contrib/libs/benchmark/test/benchmark_name_gtest.cc82
-rw-r--r--contrib/libs/benchmark/test/commandlineflags_gtest.cc228
-rw-r--r--contrib/libs/benchmark/test/statistics_gtest.cc35
-rw-r--r--contrib/libs/benchmark/test/string_util_gtest.cc152
-rw-r--r--library/cpp/testing/CMakeLists.txt1
-rw-r--r--library/cpp/testing/gbenchmark_main/CMakeLists.darwin-x86_64.txt19
-rw-r--r--library/cpp/testing/gbenchmark_main/CMakeLists.linux-aarch64.txt20
-rw-r--r--library/cpp/testing/gbenchmark_main/CMakeLists.linux-x86_64.txt20
-rw-r--r--library/cpp/testing/gbenchmark_main/CMakeLists.txt17
-rw-r--r--library/cpp/testing/gbenchmark_main/CMakeLists.windows-x86_64.txt19
-rw-r--r--ydb/core/tablet_flat/CMakeLists.darwin-x86_64.txt1
-rw-r--r--ydb/core/tablet_flat/CMakeLists.linux-aarch64.txt1
-rw-r--r--ydb/core/tablet_flat/CMakeLists.linux-x86_64.txt1
-rw-r--r--ydb/core/tablet_flat/CMakeLists.windows-x86_64.txt1
-rw-r--r--ydb/core/tablet_flat/benchmark/CMakeLists.darwin-x86_64.txt55
-rw-r--r--ydb/core/tablet_flat/benchmark/CMakeLists.linux-aarch64.txt58
-rw-r--r--ydb/core/tablet_flat/benchmark/CMakeLists.linux-x86_64.txt60
-rw-r--r--ydb/core/tablet_flat/benchmark/CMakeLists.txt17
-rw-r--r--ydb/core/tablet_flat/benchmark/CMakeLists.windows-x86_64.txt48
-rw-r--r--ydb/core/tablet_flat/benchmark/b_charge.cpp172
30 files changed, 1399 insertions, 0 deletions
diff --git a/contrib/libs/CMakeLists.darwin-x86_64.txt b/contrib/libs/CMakeLists.darwin-x86_64.txt
index dbdaed7276d..2ab8455da6b 100644
--- a/contrib/libs/CMakeLists.darwin-x86_64.txt
+++ b/contrib/libs/CMakeLists.darwin-x86_64.txt
@@ -12,6 +12,7 @@ add_subdirectory(asmglibc)
add_subdirectory(asmlib)
add_subdirectory(aws-sdk-cpp)
add_subdirectory(base64)
+add_subdirectory(benchmark)
add_subdirectory(brotli)
add_subdirectory(cctz)
add_subdirectory(crcutil)
diff --git a/contrib/libs/CMakeLists.linux-aarch64.txt b/contrib/libs/CMakeLists.linux-aarch64.txt
index c67d278e533..5592a4ab628 100644
--- a/contrib/libs/CMakeLists.linux-aarch64.txt
+++ b/contrib/libs/CMakeLists.linux-aarch64.txt
@@ -11,6 +11,7 @@ add_subdirectory(apache)
add_subdirectory(asmlib)
add_subdirectory(aws-sdk-cpp)
add_subdirectory(base64)
+add_subdirectory(benchmark)
add_subdirectory(brotli)
add_subdirectory(cctz)
add_subdirectory(crcutil)
diff --git a/contrib/libs/CMakeLists.linux-x86_64.txt b/contrib/libs/CMakeLists.linux-x86_64.txt
index 185d96e8918..51b755bab00 100644
--- a/contrib/libs/CMakeLists.linux-x86_64.txt
+++ b/contrib/libs/CMakeLists.linux-x86_64.txt
@@ -11,6 +11,7 @@ add_subdirectory(apache)
add_subdirectory(asmlib)
add_subdirectory(aws-sdk-cpp)
add_subdirectory(base64)
+add_subdirectory(benchmark)
add_subdirectory(brotli)
add_subdirectory(cctz)
add_subdirectory(crcutil)
diff --git a/contrib/libs/CMakeLists.windows-x86_64.txt b/contrib/libs/CMakeLists.windows-x86_64.txt
index 96f605c258d..facf16a4fa1 100644
--- a/contrib/libs/CMakeLists.windows-x86_64.txt
+++ b/contrib/libs/CMakeLists.windows-x86_64.txt
@@ -11,6 +11,7 @@ add_subdirectory(apache)
add_subdirectory(asmlib)
add_subdirectory(aws-sdk-cpp)
add_subdirectory(base64)
+add_subdirectory(benchmark)
add_subdirectory(brotli)
add_subdirectory(cctz)
add_subdirectory(crcutil)
diff --git a/contrib/libs/benchmark/CMakeLists.darwin-x86_64.txt b/contrib/libs/benchmark/CMakeLists.darwin-x86_64.txt
new file mode 100644
index 00000000000..ccc95a4d97a
--- /dev/null
+++ b/contrib/libs/benchmark/CMakeLists.darwin-x86_64.txt
@@ -0,0 +1,50 @@
+
+# This file was generated by the build system used internally in the Yandex monorepo.
+# Only simple modifications are allowed (adding source-files to targets, adding simple properties
+# like target_include_directories). These modifications will be ported to original
+# ya.make files by maintainers. Any complex modifications which can't be ported back to the
+# original buildsystem will not be accepted.
+
+
+
+add_library(contrib-libs-benchmark)
+target_compile_options(contrib-libs-benchmark PUBLIC
+ -DBENCHMARK_STATIC_DEFINE
+)
+target_compile_options(contrib-libs-benchmark PRIVATE
+ -DHAVE_POSIX_REGEX
+ -DHAVE_STD_REGEX
+ -DHAVE_STEADY_CLOCK
+ $<IF:$<CXX_COMPILER_ID:MSVC>,,-Wno-everything>
+)
+target_include_directories(contrib-libs-benchmark PUBLIC
+ ${CMAKE_SOURCE_DIR}/contrib/libs/benchmark/include
+)
+target_include_directories(contrib-libs-benchmark PRIVATE
+ ${CMAKE_SOURCE_DIR}/contrib/libs/benchmark/src
+)
+target_link_libraries(contrib-libs-benchmark PUBLIC
+ contrib-libs-cxxsupp
+)
+target_sources(contrib-libs-benchmark PRIVATE
+ ${CMAKE_SOURCE_DIR}/contrib/libs/benchmark/src/benchmark.cc
+ ${CMAKE_SOURCE_DIR}/contrib/libs/benchmark/src/benchmark_api_internal.cc
+ ${CMAKE_SOURCE_DIR}/contrib/libs/benchmark/src/benchmark_name.cc
+ ${CMAKE_SOURCE_DIR}/contrib/libs/benchmark/src/benchmark_register.cc
+ ${CMAKE_SOURCE_DIR}/contrib/libs/benchmark/src/benchmark_runner.cc
+ ${CMAKE_SOURCE_DIR}/contrib/libs/benchmark/src/check.cc
+ ${CMAKE_SOURCE_DIR}/contrib/libs/benchmark/src/colorprint.cc
+ ${CMAKE_SOURCE_DIR}/contrib/libs/benchmark/src/commandlineflags.cc
+ ${CMAKE_SOURCE_DIR}/contrib/libs/benchmark/src/complexity.cc
+ ${CMAKE_SOURCE_DIR}/contrib/libs/benchmark/src/console_reporter.cc
+ ${CMAKE_SOURCE_DIR}/contrib/libs/benchmark/src/counter.cc
+ ${CMAKE_SOURCE_DIR}/contrib/libs/benchmark/src/csv_reporter.cc
+ ${CMAKE_SOURCE_DIR}/contrib/libs/benchmark/src/json_reporter.cc
+ ${CMAKE_SOURCE_DIR}/contrib/libs/benchmark/src/perf_counters.cc
+ ${CMAKE_SOURCE_DIR}/contrib/libs/benchmark/src/reporter.cc
+ ${CMAKE_SOURCE_DIR}/contrib/libs/benchmark/src/sleep.cc
+ ${CMAKE_SOURCE_DIR}/contrib/libs/benchmark/src/statistics.cc
+ ${CMAKE_SOURCE_DIR}/contrib/libs/benchmark/src/string_util.cc
+ ${CMAKE_SOURCE_DIR}/contrib/libs/benchmark/src/sysinfo.cc
+ ${CMAKE_SOURCE_DIR}/contrib/libs/benchmark/src/timers.cc
+)
diff --git a/contrib/libs/benchmark/CMakeLists.linux-aarch64.txt b/contrib/libs/benchmark/CMakeLists.linux-aarch64.txt
new file mode 100644
index 00000000000..e341ad39afe
--- /dev/null
+++ b/contrib/libs/benchmark/CMakeLists.linux-aarch64.txt
@@ -0,0 +1,51 @@
+
+# This file was generated by the build system used internally in the Yandex monorepo.
+# Only simple modifications are allowed (adding source-files to targets, adding simple properties
+# like target_include_directories). These modifications will be ported to original
+# ya.make files by maintainers. Any complex modifications which can't be ported back to the
+# original buildsystem will not be accepted.
+
+
+
+add_library(contrib-libs-benchmark)
+target_compile_options(contrib-libs-benchmark PUBLIC
+ -DBENCHMARK_STATIC_DEFINE
+)
+target_compile_options(contrib-libs-benchmark PRIVATE
+ -DHAVE_POSIX_REGEX
+ -DHAVE_STD_REGEX
+ -DHAVE_STEADY_CLOCK
+ $<IF:$<CXX_COMPILER_ID:MSVC>,,-Wno-everything>
+)
+target_include_directories(contrib-libs-benchmark PUBLIC
+ ${CMAKE_SOURCE_DIR}/contrib/libs/benchmark/include
+)
+target_include_directories(contrib-libs-benchmark PRIVATE
+ ${CMAKE_SOURCE_DIR}/contrib/libs/benchmark/src
+)
+target_link_libraries(contrib-libs-benchmark PUBLIC
+ contrib-libs-linux-headers
+ contrib-libs-cxxsupp
+)
+target_sources(contrib-libs-benchmark PRIVATE
+ ${CMAKE_SOURCE_DIR}/contrib/libs/benchmark/src/benchmark.cc
+ ${CMAKE_SOURCE_DIR}/contrib/libs/benchmark/src/benchmark_api_internal.cc
+ ${CMAKE_SOURCE_DIR}/contrib/libs/benchmark/src/benchmark_name.cc
+ ${CMAKE_SOURCE_DIR}/contrib/libs/benchmark/src/benchmark_register.cc
+ ${CMAKE_SOURCE_DIR}/contrib/libs/benchmark/src/benchmark_runner.cc
+ ${CMAKE_SOURCE_DIR}/contrib/libs/benchmark/src/check.cc
+ ${CMAKE_SOURCE_DIR}/contrib/libs/benchmark/src/colorprint.cc
+ ${CMAKE_SOURCE_DIR}/contrib/libs/benchmark/src/commandlineflags.cc
+ ${CMAKE_SOURCE_DIR}/contrib/libs/benchmark/src/complexity.cc
+ ${CMAKE_SOURCE_DIR}/contrib/libs/benchmark/src/console_reporter.cc
+ ${CMAKE_SOURCE_DIR}/contrib/libs/benchmark/src/counter.cc
+ ${CMAKE_SOURCE_DIR}/contrib/libs/benchmark/src/csv_reporter.cc
+ ${CMAKE_SOURCE_DIR}/contrib/libs/benchmark/src/json_reporter.cc
+ ${CMAKE_SOURCE_DIR}/contrib/libs/benchmark/src/perf_counters.cc
+ ${CMAKE_SOURCE_DIR}/contrib/libs/benchmark/src/reporter.cc
+ ${CMAKE_SOURCE_DIR}/contrib/libs/benchmark/src/sleep.cc
+ ${CMAKE_SOURCE_DIR}/contrib/libs/benchmark/src/statistics.cc
+ ${CMAKE_SOURCE_DIR}/contrib/libs/benchmark/src/string_util.cc
+ ${CMAKE_SOURCE_DIR}/contrib/libs/benchmark/src/sysinfo.cc
+ ${CMAKE_SOURCE_DIR}/contrib/libs/benchmark/src/timers.cc
+)
diff --git a/contrib/libs/benchmark/CMakeLists.linux-x86_64.txt b/contrib/libs/benchmark/CMakeLists.linux-x86_64.txt
new file mode 100644
index 00000000000..e341ad39afe
--- /dev/null
+++ b/contrib/libs/benchmark/CMakeLists.linux-x86_64.txt
@@ -0,0 +1,51 @@
+
+# This file was generated by the build system used internally in the Yandex monorepo.
+# Only simple modifications are allowed (adding source-files to targets, adding simple properties
+# like target_include_directories). These modifications will be ported to original
+# ya.make files by maintainers. Any complex modifications which can't be ported back to the
+# original buildsystem will not be accepted.
+
+
+
+add_library(contrib-libs-benchmark)
+target_compile_options(contrib-libs-benchmark PUBLIC
+ -DBENCHMARK_STATIC_DEFINE
+)
+target_compile_options(contrib-libs-benchmark PRIVATE
+ -DHAVE_POSIX_REGEX
+ -DHAVE_STD_REGEX
+ -DHAVE_STEADY_CLOCK
+ $<IF:$<CXX_COMPILER_ID:MSVC>,,-Wno-everything>
+)
+target_include_directories(contrib-libs-benchmark PUBLIC
+ ${CMAKE_SOURCE_DIR}/contrib/libs/benchmark/include
+)
+target_include_directories(contrib-libs-benchmark PRIVATE
+ ${CMAKE_SOURCE_DIR}/contrib/libs/benchmark/src
+)
+target_link_libraries(contrib-libs-benchmark PUBLIC
+ contrib-libs-linux-headers
+ contrib-libs-cxxsupp
+)
+target_sources(contrib-libs-benchmark PRIVATE
+ ${CMAKE_SOURCE_DIR}/contrib/libs/benchmark/src/benchmark.cc
+ ${CMAKE_SOURCE_DIR}/contrib/libs/benchmark/src/benchmark_api_internal.cc
+ ${CMAKE_SOURCE_DIR}/contrib/libs/benchmark/src/benchmark_name.cc
+ ${CMAKE_SOURCE_DIR}/contrib/libs/benchmark/src/benchmark_register.cc
+ ${CMAKE_SOURCE_DIR}/contrib/libs/benchmark/src/benchmark_runner.cc
+ ${CMAKE_SOURCE_DIR}/contrib/libs/benchmark/src/check.cc
+ ${CMAKE_SOURCE_DIR}/contrib/libs/benchmark/src/colorprint.cc
+ ${CMAKE_SOURCE_DIR}/contrib/libs/benchmark/src/commandlineflags.cc
+ ${CMAKE_SOURCE_DIR}/contrib/libs/benchmark/src/complexity.cc
+ ${CMAKE_SOURCE_DIR}/contrib/libs/benchmark/src/console_reporter.cc
+ ${CMAKE_SOURCE_DIR}/contrib/libs/benchmark/src/counter.cc
+ ${CMAKE_SOURCE_DIR}/contrib/libs/benchmark/src/csv_reporter.cc
+ ${CMAKE_SOURCE_DIR}/contrib/libs/benchmark/src/json_reporter.cc
+ ${CMAKE_SOURCE_DIR}/contrib/libs/benchmark/src/perf_counters.cc
+ ${CMAKE_SOURCE_DIR}/contrib/libs/benchmark/src/reporter.cc
+ ${CMAKE_SOURCE_DIR}/contrib/libs/benchmark/src/sleep.cc
+ ${CMAKE_SOURCE_DIR}/contrib/libs/benchmark/src/statistics.cc
+ ${CMAKE_SOURCE_DIR}/contrib/libs/benchmark/src/string_util.cc
+ ${CMAKE_SOURCE_DIR}/contrib/libs/benchmark/src/sysinfo.cc
+ ${CMAKE_SOURCE_DIR}/contrib/libs/benchmark/src/timers.cc
+)
diff --git a/contrib/libs/benchmark/CMakeLists.txt b/contrib/libs/benchmark/CMakeLists.txt
new file mode 100644
index 00000000000..f8b31df0c11
--- /dev/null
+++ b/contrib/libs/benchmark/CMakeLists.txt
@@ -0,0 +1,17 @@
+
+# This file was generated by the build system used internally in the Yandex monorepo.
+# Only simple modifications are allowed (adding source-files to targets, adding simple properties
+# like target_include_directories). These modifications will be ported to original
+# ya.make files by maintainers. Any complex modifications which can't be ported back to the
+# original buildsystem will not be accepted.
+
+
+if (CMAKE_SYSTEM_NAME STREQUAL "Linux" AND CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64" AND NOT HAVE_CUDA)
+ include(CMakeLists.linux-aarch64.txt)
+elseif (CMAKE_SYSTEM_NAME STREQUAL "Darwin" AND CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
+ include(CMakeLists.darwin-x86_64.txt)
+elseif (WIN32 AND CMAKE_SYSTEM_PROCESSOR STREQUAL "AMD64" AND NOT HAVE_CUDA)
+ include(CMakeLists.windows-x86_64.txt)
+elseif (CMAKE_SYSTEM_NAME STREQUAL "Linux" AND CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" AND NOT HAVE_CUDA)
+ include(CMakeLists.linux-x86_64.txt)
+endif()
diff --git a/contrib/libs/benchmark/CMakeLists.windows-x86_64.txt b/contrib/libs/benchmark/CMakeLists.windows-x86_64.txt
new file mode 100644
index 00000000000..ccc95a4d97a
--- /dev/null
+++ b/contrib/libs/benchmark/CMakeLists.windows-x86_64.txt
@@ -0,0 +1,50 @@
+
+# This file was generated by the build system used internally in the Yandex monorepo.
+# Only simple modifications are allowed (adding source-files to targets, adding simple properties
+# like target_include_directories). These modifications will be ported to original
+# ya.make files by maintainers. Any complex modifications which can't be ported back to the
+# original buildsystem will not be accepted.
+
+
+
+add_library(contrib-libs-benchmark)
+target_compile_options(contrib-libs-benchmark PUBLIC
+ -DBENCHMARK_STATIC_DEFINE
+)
+target_compile_options(contrib-libs-benchmark PRIVATE
+ -DHAVE_POSIX_REGEX
+ -DHAVE_STD_REGEX
+ -DHAVE_STEADY_CLOCK
+ $<IF:$<CXX_COMPILER_ID:MSVC>,,-Wno-everything>
+)
+target_include_directories(contrib-libs-benchmark PUBLIC
+ ${CMAKE_SOURCE_DIR}/contrib/libs/benchmark/include
+)
+target_include_directories(contrib-libs-benchmark PRIVATE
+ ${CMAKE_SOURCE_DIR}/contrib/libs/benchmark/src
+)
+target_link_libraries(contrib-libs-benchmark PUBLIC
+ contrib-libs-cxxsupp
+)
+target_sources(contrib-libs-benchmark PRIVATE
+ ${CMAKE_SOURCE_DIR}/contrib/libs/benchmark/src/benchmark.cc
+ ${CMAKE_SOURCE_DIR}/contrib/libs/benchmark/src/benchmark_api_internal.cc
+ ${CMAKE_SOURCE_DIR}/contrib/libs/benchmark/src/benchmark_name.cc
+ ${CMAKE_SOURCE_DIR}/contrib/libs/benchmark/src/benchmark_register.cc
+ ${CMAKE_SOURCE_DIR}/contrib/libs/benchmark/src/benchmark_runner.cc
+ ${CMAKE_SOURCE_DIR}/contrib/libs/benchmark/src/check.cc
+ ${CMAKE_SOURCE_DIR}/contrib/libs/benchmark/src/colorprint.cc
+ ${CMAKE_SOURCE_DIR}/contrib/libs/benchmark/src/commandlineflags.cc
+ ${CMAKE_SOURCE_DIR}/contrib/libs/benchmark/src/complexity.cc
+ ${CMAKE_SOURCE_DIR}/contrib/libs/benchmark/src/console_reporter.cc
+ ${CMAKE_SOURCE_DIR}/contrib/libs/benchmark/src/counter.cc
+ ${CMAKE_SOURCE_DIR}/contrib/libs/benchmark/src/csv_reporter.cc
+ ${CMAKE_SOURCE_DIR}/contrib/libs/benchmark/src/json_reporter.cc
+ ${CMAKE_SOURCE_DIR}/contrib/libs/benchmark/src/perf_counters.cc
+ ${CMAKE_SOURCE_DIR}/contrib/libs/benchmark/src/reporter.cc
+ ${CMAKE_SOURCE_DIR}/contrib/libs/benchmark/src/sleep.cc
+ ${CMAKE_SOURCE_DIR}/contrib/libs/benchmark/src/statistics.cc
+ ${CMAKE_SOURCE_DIR}/contrib/libs/benchmark/src/string_util.cc
+ ${CMAKE_SOURCE_DIR}/contrib/libs/benchmark/src/sysinfo.cc
+ ${CMAKE_SOURCE_DIR}/contrib/libs/benchmark/src/timers.cc
+)
diff --git a/contrib/libs/benchmark/test/benchmark_gtest.cc b/contrib/libs/benchmark/test/benchmark_gtest.cc
new file mode 100644
index 00000000000..2c9e555d92d
--- /dev/null
+++ b/contrib/libs/benchmark/test/benchmark_gtest.cc
@@ -0,0 +1,169 @@
+#include <map>
+#include <string>
+#include <vector>
+
+#include "../src/benchmark_register.h"
+#include "benchmark/benchmark.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+namespace benchmark {
+namespace internal {
+
+namespace {
+
+TEST(AddRangeTest, Simple) {
+ std::vector<int> dst;
+ AddRange(&dst, 1, 2, 2);
+ EXPECT_THAT(dst, testing::ElementsAre(1, 2));
+}
+
+TEST(AddRangeTest, Simple64) {
+ std::vector<int64_t> dst;
+ AddRange(&dst, static_cast<int64_t>(1), static_cast<int64_t>(2), 2);
+ EXPECT_THAT(dst, testing::ElementsAre(1, 2));
+}
+
+TEST(AddRangeTest, Advanced) {
+ std::vector<int> dst;
+ AddRange(&dst, 5, 15, 2);
+ EXPECT_THAT(dst, testing::ElementsAre(5, 8, 15));
+}
+
+TEST(AddRangeTest, Advanced64) {
+ std::vector<int64_t> dst;
+ AddRange(&dst, static_cast<int64_t>(5), static_cast<int64_t>(15), 2);
+ EXPECT_THAT(dst, testing::ElementsAre(5, 8, 15));
+}
+
+TEST(AddRangeTest, FullRange8) {
+ std::vector<int8_t> dst;
+ AddRange(&dst, int8_t{1}, std::numeric_limits<int8_t>::max(), int8_t{8});
+ EXPECT_THAT(
+ dst, testing::ElementsAre(int8_t{1}, int8_t{8}, int8_t{64}, int8_t{127}));
+}
+
+TEST(AddRangeTest, FullRange64) {
+ std::vector<int64_t> dst;
+ AddRange(&dst, int64_t{1}, std::numeric_limits<int64_t>::max(), 1024);
+ EXPECT_THAT(
+ dst, testing::ElementsAre(1LL, 1024LL, 1048576LL, 1073741824LL,
+ 1099511627776LL, 1125899906842624LL,
+ 1152921504606846976LL, 9223372036854775807LL));
+}
+
+TEST(AddRangeTest, NegativeRanges) {
+ std::vector<int> dst;
+ AddRange(&dst, -8, 0, 2);
+ EXPECT_THAT(dst, testing::ElementsAre(-8, -4, -2, -1, 0));
+}
+
+TEST(AddRangeTest, StrictlyNegative) {
+ std::vector<int> dst;
+ AddRange(&dst, -8, -1, 2);
+ EXPECT_THAT(dst, testing::ElementsAre(-8, -4, -2, -1));
+}
+
+TEST(AddRangeTest, SymmetricNegativeRanges) {
+ std::vector<int> dst;
+ AddRange(&dst, -8, 8, 2);
+ EXPECT_THAT(dst, testing::ElementsAre(-8, -4, -2, -1, 0, 1, 2, 4, 8));
+}
+
+TEST(AddRangeTest, SymmetricNegativeRangesOddMult) {
+ std::vector<int> dst;
+ AddRange(&dst, -30, 32, 5);
+ EXPECT_THAT(dst, testing::ElementsAre(-30, -25, -5, -1, 0, 1, 5, 25, 32));
+}
+
+TEST(AddRangeTest, NegativeRangesAsymmetric) {
+ std::vector<int> dst;
+ AddRange(&dst, -3, 5, 2);
+ EXPECT_THAT(dst, testing::ElementsAre(-3, -2, -1, 0, 1, 2, 4, 5));
+}
+
+TEST(AddRangeTest, NegativeRangesLargeStep) {
+ // Always include -1, 0, 1 when crossing zero.
+ std::vector<int> dst;
+ AddRange(&dst, -8, 8, 10);
+ EXPECT_THAT(dst, testing::ElementsAre(-8, -1, 0, 1, 8));
+}
+
+TEST(AddRangeTest, ZeroOnlyRange) {
+ std::vector<int> dst;
+ AddRange(&dst, 0, 0, 2);
+ EXPECT_THAT(dst, testing::ElementsAre(0));
+}
+
+TEST(AddRangeTest, ZeroStartingRange) {
+ std::vector<int> dst;
+ AddRange(&dst, 0, 2, 2);
+ EXPECT_THAT(dst, testing::ElementsAre(0, 1, 2));
+}
+
+TEST(AddRangeTest, NegativeRange64) {
+ std::vector<int64_t> dst;
+ AddRange<int64_t>(&dst, -4, 4, 2);
+ EXPECT_THAT(dst, testing::ElementsAre(-4, -2, -1, 0, 1, 2, 4));
+}
+
+TEST(AddRangeTest, NegativeRangePreservesExistingOrder) {
+ // If elements already exist in the range, ensure we don't change
+ // their ordering by adding negative values.
+ std::vector<int64_t> dst = {1, 2, 3};
+ AddRange<int64_t>(&dst, -2, 2, 2);
+ EXPECT_THAT(dst, testing::ElementsAre(1, 2, 3, -2, -1, 0, 1, 2));
+}
+
+TEST(AddRangeTest, FullNegativeRange64) {
+ std::vector<int64_t> dst;
+ const auto min = std::numeric_limits<int64_t>::min();
+ const auto max = std::numeric_limits<int64_t>::max();
+ AddRange(&dst, min, max, 1024);
+ EXPECT_THAT(
+ dst, testing::ElementsAreArray(std::vector<int64_t>{
+ min, -1152921504606846976LL, -1125899906842624LL,
+ -1099511627776LL, -1073741824LL, -1048576LL, -1024LL, -1LL, 0LL,
+ 1LL, 1024LL, 1048576LL, 1073741824LL, 1099511627776LL,
+ 1125899906842624LL, 1152921504606846976LL, max}));
+}
+
+TEST(AddRangeTest, Simple8) {
+ std::vector<int8_t> dst;
+ AddRange<int8_t>(&dst, int8_t{1}, int8_t{8}, int8_t{2});
+ EXPECT_THAT(dst,
+ testing::ElementsAre(int8_t{1}, int8_t{2}, int8_t{4}, int8_t{8}));
+}
+
+TEST(AddCustomContext, Simple) {
+ std::map<std::string, std::string> *&global_context = GetGlobalContext();
+ EXPECT_THAT(global_context, nullptr);
+
+ AddCustomContext("foo", "bar");
+ AddCustomContext("baz", "qux");
+
+ EXPECT_THAT(*global_context,
+ testing::UnorderedElementsAre(testing::Pair("foo", "bar"),
+ testing::Pair("baz", "qux")));
+
+ delete global_context;
+ global_context = nullptr;
+}
+
+TEST(AddCustomContext, DuplicateKey) {
+ std::map<std::string, std::string> *&global_context = GetGlobalContext();
+ EXPECT_THAT(global_context, nullptr);
+
+ AddCustomContext("foo", "bar");
+ AddCustomContext("foo", "qux");
+
+ EXPECT_THAT(*global_context,
+ testing::UnorderedElementsAre(testing::Pair("foo", "bar")));
+
+ delete global_context;
+ global_context = nullptr;
+}
+
+} // namespace
+} // namespace internal
+} // namespace benchmark
diff --git a/contrib/libs/benchmark/test/benchmark_name_gtest.cc b/contrib/libs/benchmark/test/benchmark_name_gtest.cc
new file mode 100644
index 00000000000..0a6746d04df
--- /dev/null
+++ b/contrib/libs/benchmark/test/benchmark_name_gtest.cc
@@ -0,0 +1,82 @@
+#include "benchmark/benchmark.h"
+#include "gtest/gtest.h"
+
+namespace {
+
+using namespace benchmark;
+using namespace benchmark::internal;
+
+TEST(BenchmarkNameTest, Empty) {
+ const auto name = BenchmarkName();
+ EXPECT_EQ(name.str(), std::string());
+}
+
+TEST(BenchmarkNameTest, FunctionName) {
+ auto name = BenchmarkName();
+ name.function_name = "function_name";
+ EXPECT_EQ(name.str(), "function_name");
+}
+
+TEST(BenchmarkNameTest, FunctionNameAndArgs) {
+ auto name = BenchmarkName();
+ name.function_name = "function_name";
+ name.args = "some_args:3/4/5";
+ EXPECT_EQ(name.str(), "function_name/some_args:3/4/5");
+}
+
+TEST(BenchmarkNameTest, MinTime) {
+ auto name = BenchmarkName();
+ name.function_name = "function_name";
+ name.args = "some_args:3/4";
+ name.min_time = "min_time:3.4s";
+ EXPECT_EQ(name.str(), "function_name/some_args:3/4/min_time:3.4s");
+}
+
+TEST(BenchmarkNameTest, MinWarmUpTime) {
+ auto name = BenchmarkName();
+ name.function_name = "function_name";
+ name.args = "some_args:3/4";
+ name.min_warmup_time = "min_warmup_time:3.5s";
+ EXPECT_EQ(name.str(), "function_name/some_args:3/4/min_warmup_time:3.5s");
+}
+
+TEST(BenchmarkNameTest, Iterations) {
+ auto name = BenchmarkName();
+ name.function_name = "function_name";
+ name.min_time = "min_time:3.4s";
+ name.iterations = "iterations:42";
+ EXPECT_EQ(name.str(), "function_name/min_time:3.4s/iterations:42");
+}
+
+TEST(BenchmarkNameTest, Repetitions) {
+ auto name = BenchmarkName();
+ name.function_name = "function_name";
+ name.min_time = "min_time:3.4s";
+ name.repetitions = "repetitions:24";
+ EXPECT_EQ(name.str(), "function_name/min_time:3.4s/repetitions:24");
+}
+
+TEST(BenchmarkNameTest, TimeType) {
+ auto name = BenchmarkName();
+ name.function_name = "function_name";
+ name.min_time = "min_time:3.4s";
+ name.time_type = "hammer_time";
+ EXPECT_EQ(name.str(), "function_name/min_time:3.4s/hammer_time");
+}
+
+TEST(BenchmarkNameTest, Threads) {
+ auto name = BenchmarkName();
+ name.function_name = "function_name";
+ name.min_time = "min_time:3.4s";
+ name.threads = "threads:256";
+ EXPECT_EQ(name.str(), "function_name/min_time:3.4s/threads:256");
+}
+
+TEST(BenchmarkNameTest, TestEmptyFunctionName) {
+ auto name = BenchmarkName();
+ name.args = "first:3/second:4";
+ name.threads = "threads:22";
+ EXPECT_EQ(name.str(), "first:3/second:4/threads:22");
+}
+
+} // end namespace
diff --git a/contrib/libs/benchmark/test/commandlineflags_gtest.cc b/contrib/libs/benchmark/test/commandlineflags_gtest.cc
new file mode 100644
index 00000000000..8412008ffe3
--- /dev/null
+++ b/contrib/libs/benchmark/test/commandlineflags_gtest.cc
@@ -0,0 +1,228 @@
+#include <cstdlib>
+
+#include "../src/commandlineflags.h"
+#include "../src/internal_macros.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+namespace benchmark {
+namespace {
+
+#if defined(BENCHMARK_OS_WINDOWS)
+int setenv(const char* name, const char* value, int overwrite) {
+ if (!overwrite) {
+ // NOTE: getenv_s is far superior but not available under mingw.
+ char* env_value = getenv(name);
+ if (env_value == nullptr) {
+ return -1;
+ }
+ }
+ return _putenv_s(name, value);
+}
+
+int unsetenv(const char* name) { return _putenv_s(name, ""); }
+
+#endif // BENCHMARK_OS_WINDOWS
+
+TEST(BoolFromEnv, Default) {
+ ASSERT_EQ(unsetenv("NOT_IN_ENV"), 0);
+ EXPECT_EQ(BoolFromEnv("not_in_env", true), true);
+}
+
+TEST(BoolFromEnv, False) {
+ ASSERT_EQ(setenv("IN_ENV", "0", 1), 0);
+ EXPECT_EQ(BoolFromEnv("in_env", true), false);
+ unsetenv("IN_ENV");
+
+ ASSERT_EQ(setenv("IN_ENV", "N", 1), 0);
+ EXPECT_EQ(BoolFromEnv("in_env", true), false);
+ unsetenv("IN_ENV");
+
+ ASSERT_EQ(setenv("IN_ENV", "n", 1), 0);
+ EXPECT_EQ(BoolFromEnv("in_env", true), false);
+ unsetenv("IN_ENV");
+
+ ASSERT_EQ(setenv("IN_ENV", "NO", 1), 0);
+ EXPECT_EQ(BoolFromEnv("in_env", true), false);
+ unsetenv("IN_ENV");
+
+ ASSERT_EQ(setenv("IN_ENV", "No", 1), 0);
+ EXPECT_EQ(BoolFromEnv("in_env", true), false);
+ unsetenv("IN_ENV");
+
+ ASSERT_EQ(setenv("IN_ENV", "no", 1), 0);
+ EXPECT_EQ(BoolFromEnv("in_env", true), false);
+ unsetenv("IN_ENV");
+
+ ASSERT_EQ(setenv("IN_ENV", "F", 1), 0);
+ EXPECT_EQ(BoolFromEnv("in_env", true), false);
+ unsetenv("IN_ENV");
+
+ ASSERT_EQ(setenv("IN_ENV", "f", 1), 0);
+ EXPECT_EQ(BoolFromEnv("in_env", true), false);
+ unsetenv("IN_ENV");
+
+ ASSERT_EQ(setenv("IN_ENV", "FALSE", 1), 0);
+ EXPECT_EQ(BoolFromEnv("in_env", true), false);
+ unsetenv("IN_ENV");
+
+ ASSERT_EQ(setenv("IN_ENV", "False", 1), 0);
+ EXPECT_EQ(BoolFromEnv("in_env", true), false);
+ unsetenv("IN_ENV");
+
+ ASSERT_EQ(setenv("IN_ENV", "false", 1), 0);
+ EXPECT_EQ(BoolFromEnv("in_env", true), false);
+ unsetenv("IN_ENV");
+
+ ASSERT_EQ(setenv("IN_ENV", "OFF", 1), 0);
+ EXPECT_EQ(BoolFromEnv("in_env", true), false);
+ unsetenv("IN_ENV");
+
+ ASSERT_EQ(setenv("IN_ENV", "Off", 1), 0);
+ EXPECT_EQ(BoolFromEnv("in_env", true), false);
+ unsetenv("IN_ENV");
+
+ ASSERT_EQ(setenv("IN_ENV", "off", 1), 0);
+ EXPECT_EQ(BoolFromEnv("in_env", true), false);
+ unsetenv("IN_ENV");
+}
+
+TEST(BoolFromEnv, True) {
+ ASSERT_EQ(setenv("IN_ENV", "1", 1), 0);
+ EXPECT_EQ(BoolFromEnv("in_env", false), true);
+ unsetenv("IN_ENV");
+
+ ASSERT_EQ(setenv("IN_ENV", "Y", 1), 0);
+ EXPECT_EQ(BoolFromEnv("in_env", false), true);
+ unsetenv("IN_ENV");
+
+ ASSERT_EQ(setenv("IN_ENV", "y", 1), 0);
+ EXPECT_EQ(BoolFromEnv("in_env", false), true);
+ unsetenv("IN_ENV");
+
+ ASSERT_EQ(setenv("IN_ENV", "YES", 1), 0);
+ EXPECT_EQ(BoolFromEnv("in_env", false), true);
+ unsetenv("IN_ENV");
+
+ ASSERT_EQ(setenv("IN_ENV", "Yes", 1), 0);
+ EXPECT_EQ(BoolFromEnv("in_env", false), true);
+ unsetenv("IN_ENV");
+
+ ASSERT_EQ(setenv("IN_ENV", "yes", 1), 0);
+ EXPECT_EQ(BoolFromEnv("in_env", false), true);
+ unsetenv("IN_ENV");
+
+ ASSERT_EQ(setenv("IN_ENV", "T", 1), 0);
+ EXPECT_EQ(BoolFromEnv("in_env", false), true);
+ unsetenv("IN_ENV");
+
+ ASSERT_EQ(setenv("IN_ENV", "t", 1), 0);
+ EXPECT_EQ(BoolFromEnv("in_env", false), true);
+ unsetenv("IN_ENV");
+
+ ASSERT_EQ(setenv("IN_ENV", "TRUE", 1), 0);
+ EXPECT_EQ(BoolFromEnv("in_env", false), true);
+ unsetenv("IN_ENV");
+
+ ASSERT_EQ(setenv("IN_ENV", "True", 1), 0);
+ EXPECT_EQ(BoolFromEnv("in_env", false), true);
+ unsetenv("IN_ENV");
+
+ ASSERT_EQ(setenv("IN_ENV", "true", 1), 0);
+ EXPECT_EQ(BoolFromEnv("in_env", false), true);
+ unsetenv("IN_ENV");
+
+ ASSERT_EQ(setenv("IN_ENV", "ON", 1), 0);
+ EXPECT_EQ(BoolFromEnv("in_env", false), true);
+ unsetenv("IN_ENV");
+
+ ASSERT_EQ(setenv("IN_ENV", "On", 1), 0);
+ EXPECT_EQ(BoolFromEnv("in_env", false), true);
+ unsetenv("IN_ENV");
+
+ ASSERT_EQ(setenv("IN_ENV", "on", 1), 0);
+ EXPECT_EQ(BoolFromEnv("in_env", false), true);
+ unsetenv("IN_ENV");
+
+#ifndef BENCHMARK_OS_WINDOWS
+ ASSERT_EQ(setenv("IN_ENV", "", 1), 0);
+ EXPECT_EQ(BoolFromEnv("in_env", false), true);
+ unsetenv("IN_ENV");
+#endif
+}
+
+TEST(Int32FromEnv, NotInEnv) {
+ ASSERT_EQ(unsetenv("NOT_IN_ENV"), 0);
+ EXPECT_EQ(Int32FromEnv("not_in_env", 42), 42);
+}
+
+TEST(Int32FromEnv, InvalidInteger) {
+ ASSERT_EQ(setenv("IN_ENV", "foo", 1), 0);
+ EXPECT_EQ(Int32FromEnv("in_env", 42), 42);
+ unsetenv("IN_ENV");
+}
+
+TEST(Int32FromEnv, ValidInteger) {
+ ASSERT_EQ(setenv("IN_ENV", "42", 1), 0);
+ EXPECT_EQ(Int32FromEnv("in_env", 64), 42);
+ unsetenv("IN_ENV");
+}
+
+TEST(DoubleFromEnv, NotInEnv) {
+ ASSERT_EQ(unsetenv("NOT_IN_ENV"), 0);
+ EXPECT_EQ(DoubleFromEnv("not_in_env", 0.51), 0.51);
+}
+
+TEST(DoubleFromEnv, InvalidReal) {
+ ASSERT_EQ(setenv("IN_ENV", "foo", 1), 0);
+ EXPECT_EQ(DoubleFromEnv("in_env", 0.51), 0.51);
+ unsetenv("IN_ENV");
+}
+
+TEST(DoubleFromEnv, ValidReal) {
+ ASSERT_EQ(setenv("IN_ENV", "0.51", 1), 0);
+ EXPECT_EQ(DoubleFromEnv("in_env", 0.71), 0.51);
+ unsetenv("IN_ENV");
+}
+
+TEST(StringFromEnv, Default) {
+ ASSERT_EQ(unsetenv("NOT_IN_ENV"), 0);
+ EXPECT_STREQ(StringFromEnv("not_in_env", "foo"), "foo");
+}
+
+TEST(StringFromEnv, Valid) {
+ ASSERT_EQ(setenv("IN_ENV", "foo", 1), 0);
+ EXPECT_STREQ(StringFromEnv("in_env", "bar"), "foo");
+ unsetenv("IN_ENV");
+}
+
+TEST(KvPairsFromEnv, Default) {
+ ASSERT_EQ(unsetenv("NOT_IN_ENV"), 0);
+ EXPECT_THAT(KvPairsFromEnv("not_in_env", {{"foo", "bar"}}),
+ testing::ElementsAre(testing::Pair("foo", "bar")));
+}
+
+TEST(KvPairsFromEnv, MalformedReturnsDefault) {
+ ASSERT_EQ(setenv("IN_ENV", "foo", 1), 0);
+ EXPECT_THAT(KvPairsFromEnv("in_env", {{"foo", "bar"}}),
+ testing::ElementsAre(testing::Pair("foo", "bar")));
+ unsetenv("IN_ENV");
+}
+
+TEST(KvPairsFromEnv, Single) {
+ ASSERT_EQ(setenv("IN_ENV", "foo=bar", 1), 0);
+ EXPECT_THAT(KvPairsFromEnv("in_env", {}),
+ testing::ElementsAre(testing::Pair("foo", "bar")));
+ unsetenv("IN_ENV");
+}
+
+TEST(KvPairsFromEnv, Multiple) {
+ ASSERT_EQ(setenv("IN_ENV", "foo=bar,baz=qux", 1), 0);
+ EXPECT_THAT(KvPairsFromEnv("in_env", {}),
+ testing::UnorderedElementsAre(testing::Pair("foo", "bar"),
+ testing::Pair("baz", "qux")));
+ unsetenv("IN_ENV");
+}
+
+} // namespace
+} // namespace benchmark
diff --git a/contrib/libs/benchmark/test/statistics_gtest.cc b/contrib/libs/benchmark/test/statistics_gtest.cc
new file mode 100644
index 00000000000..1de2d87d4ba
--- /dev/null
+++ b/contrib/libs/benchmark/test/statistics_gtest.cc
@@ -0,0 +1,35 @@
+//===---------------------------------------------------------------------===//
+// statistics_test - Unit tests for src/statistics.cc
+//===---------------------------------------------------------------------===//
+
+#include "../src/statistics.h"
+#include "gtest/gtest.h"
+
+namespace {
+TEST(StatisticsTest, Mean) {
+ EXPECT_DOUBLE_EQ(benchmark::StatisticsMean({42, 42, 42, 42}), 42.0);
+ EXPECT_DOUBLE_EQ(benchmark::StatisticsMean({1, 2, 3, 4}), 2.5);
+ EXPECT_DOUBLE_EQ(benchmark::StatisticsMean({1, 2, 5, 10, 10, 14}), 7.0);
+}
+
+TEST(StatisticsTest, Median) {
+ EXPECT_DOUBLE_EQ(benchmark::StatisticsMedian({42, 42, 42, 42}), 42.0);
+ EXPECT_DOUBLE_EQ(benchmark::StatisticsMedian({1, 2, 3, 4}), 2.5);
+ EXPECT_DOUBLE_EQ(benchmark::StatisticsMedian({1, 2, 5, 10, 10}), 5.0);
+}
+
+TEST(StatisticsTest, StdDev) {
+ EXPECT_DOUBLE_EQ(benchmark::StatisticsStdDev({101, 101, 101, 101}), 0.0);
+ EXPECT_DOUBLE_EQ(benchmark::StatisticsStdDev({1, 2, 3}), 1.0);
+ EXPECT_DOUBLE_EQ(benchmark::StatisticsStdDev({2.5, 2.4, 3.3, 4.2, 5.1}),
+ 1.151086443322134);
+}
+
+TEST(StatisticsTest, CV) {
+ EXPECT_DOUBLE_EQ(benchmark::StatisticsCV({101, 101, 101, 101}), 0.0);
+ EXPECT_DOUBLE_EQ(benchmark::StatisticsCV({1, 2, 3}), 1. / 2.);
+ EXPECT_DOUBLE_EQ(benchmark::StatisticsCV({2.5, 2.4, 3.3, 4.2, 5.1}),
+ 0.32888184094918121);
+}
+
+} // end namespace
diff --git a/contrib/libs/benchmark/test/string_util_gtest.cc b/contrib/libs/benchmark/test/string_util_gtest.cc
new file mode 100644
index 00000000000..698f2d43eb8
--- /dev/null
+++ b/contrib/libs/benchmark/test/string_util_gtest.cc
@@ -0,0 +1,152 @@
+//===---------------------------------------------------------------------===//
+// statistics_test - Unit tests for src/statistics.cc
+//===---------------------------------------------------------------------===//
+
+#include "../src/internal_macros.h"
+#include "../src/string_util.h"
+#include "gtest/gtest.h"
+
+namespace {
+TEST(StringUtilTest, stoul) {
+ {
+ size_t pos = 0;
+ EXPECT_EQ(0ul, benchmark::stoul("0", &pos));
+ EXPECT_EQ(1ul, pos);
+ }
+ {
+ size_t pos = 0;
+ EXPECT_EQ(7ul, benchmark::stoul("7", &pos));
+ EXPECT_EQ(1ul, pos);
+ }
+ {
+ size_t pos = 0;
+ EXPECT_EQ(135ul, benchmark::stoul("135", &pos));
+ EXPECT_EQ(3ul, pos);
+ }
+#if ULONG_MAX == 0xFFFFFFFFul
+ {
+ size_t pos = 0;
+ EXPECT_EQ(0xFFFFFFFFul, benchmark::stoul("4294967295", &pos));
+ EXPECT_EQ(10ul, pos);
+ }
+#elif ULONG_MAX == 0xFFFFFFFFFFFFFFFFul
+ {
+ size_t pos = 0;
+ EXPECT_EQ(0xFFFFFFFFFFFFFFFFul,
+ benchmark::stoul("18446744073709551615", &pos));
+ EXPECT_EQ(20ul, pos);
+ }
+#endif
+ {
+ size_t pos = 0;
+ EXPECT_EQ(10ul, benchmark::stoul("1010", &pos, 2));
+ EXPECT_EQ(4ul, pos);
+ }
+ {
+ size_t pos = 0;
+ EXPECT_EQ(520ul, benchmark::stoul("1010", &pos, 8));
+ EXPECT_EQ(4ul, pos);
+ }
+ {
+ size_t pos = 0;
+ EXPECT_EQ(1010ul, benchmark::stoul("1010", &pos, 10));
+ EXPECT_EQ(4ul, pos);
+ }
+ {
+ size_t pos = 0;
+ EXPECT_EQ(4112ul, benchmark::stoul("1010", &pos, 16));
+ EXPECT_EQ(4ul, pos);
+ }
+ {
+ size_t pos = 0;
+ EXPECT_EQ(0xBEEFul, benchmark::stoul("BEEF", &pos, 16));
+ EXPECT_EQ(4ul, pos);
+ }
+#ifndef BENCHMARK_HAS_NO_EXCEPTIONS
+ { ASSERT_THROW(benchmark::stoul("this is a test"), std::invalid_argument); }
+#endif
+}
+
+TEST(StringUtilTest, stoi){{size_t pos = 0;
+EXPECT_EQ(0, benchmark::stoi("0", &pos));
+EXPECT_EQ(1ul, pos);
+} // namespace
+{
+ size_t pos = 0;
+ EXPECT_EQ(-17, benchmark::stoi("-17", &pos));
+ EXPECT_EQ(3ul, pos);
+}
+{
+ size_t pos = 0;
+ EXPECT_EQ(1357, benchmark::stoi("1357", &pos));
+ EXPECT_EQ(4ul, pos);
+}
+{
+ size_t pos = 0;
+ EXPECT_EQ(10, benchmark::stoi("1010", &pos, 2));
+ EXPECT_EQ(4ul, pos);
+}
+{
+ size_t pos = 0;
+ EXPECT_EQ(520, benchmark::stoi("1010", &pos, 8));
+ EXPECT_EQ(4ul, pos);
+}
+{
+ size_t pos = 0;
+ EXPECT_EQ(1010, benchmark::stoi("1010", &pos, 10));
+ EXPECT_EQ(4ul, pos);
+}
+{
+ size_t pos = 0;
+ EXPECT_EQ(4112, benchmark::stoi("1010", &pos, 16));
+ EXPECT_EQ(4ul, pos);
+}
+{
+ size_t pos = 0;
+ EXPECT_EQ(0xBEEF, benchmark::stoi("BEEF", &pos, 16));
+ EXPECT_EQ(4ul, pos);
+}
+#ifndef BENCHMARK_HAS_NO_EXCEPTIONS
+{ ASSERT_THROW(benchmark::stoi("this is a test"), std::invalid_argument); }
+#endif
+}
+
+TEST(StringUtilTest, stod){{size_t pos = 0;
+EXPECT_EQ(0.0, benchmark::stod("0", &pos));
+EXPECT_EQ(1ul, pos);
+}
+{
+ size_t pos = 0;
+ EXPECT_EQ(-84.0, benchmark::stod("-84", &pos));
+ EXPECT_EQ(3ul, pos);
+}
+{
+ size_t pos = 0;
+ EXPECT_EQ(1234.0, benchmark::stod("1234", &pos));
+ EXPECT_EQ(4ul, pos);
+}
+{
+ size_t pos = 0;
+ EXPECT_EQ(1.5, benchmark::stod("1.5", &pos));
+ EXPECT_EQ(3ul, pos);
+}
+{
+ size_t pos = 0;
+ /* Note: exactly representable as double */
+ EXPECT_EQ(-1.25e+9, benchmark::stod("-1.25e+9", &pos));
+ EXPECT_EQ(8ul, pos);
+}
+#ifndef BENCHMARK_HAS_NO_EXCEPTIONS
+{ ASSERT_THROW(benchmark::stod("this is a test"), std::invalid_argument); }
+#endif
+}
+
+TEST(StringUtilTest, StrSplit) {
+ EXPECT_EQ(benchmark::StrSplit("", ','), std::vector<std::string>{});
+ EXPECT_EQ(benchmark::StrSplit("hello", ','),
+ std::vector<std::string>({"hello"}));
+ EXPECT_EQ(benchmark::StrSplit("hello,there,is,more", ','),
+ std::vector<std::string>({"hello", "there", "is", "more"}));
+}
+
+} // end namespace
diff --git a/library/cpp/testing/CMakeLists.txt b/library/cpp/testing/CMakeLists.txt
index 23be63b053b..38ecc236cf3 100644
--- a/library/cpp/testing/CMakeLists.txt
+++ b/library/cpp/testing/CMakeLists.txt
@@ -8,6 +8,7 @@
add_subdirectory(benchmark)
add_subdirectory(common)
+add_subdirectory(gbenchmark_main)
add_subdirectory(gmock_in_unittest)
add_subdirectory(gtest)
add_subdirectory(gtest_extensions)
diff --git a/library/cpp/testing/gbenchmark_main/CMakeLists.darwin-x86_64.txt b/library/cpp/testing/gbenchmark_main/CMakeLists.darwin-x86_64.txt
new file mode 100644
index 00000000000..3253a09a82e
--- /dev/null
+++ b/library/cpp/testing/gbenchmark_main/CMakeLists.darwin-x86_64.txt
@@ -0,0 +1,19 @@
+
+# This file was generated by the build system used internally in the Yandex monorepo.
+# Only simple modifications are allowed (adding source-files to targets, adding simple properties
+# like target_include_directories). These modifications will be ported to original
+# ya.make files by maintainers. Any complex modifications which can't be ported back to the
+# original buildsystem will not be accepted.
+
+
+
+add_library(cpp-testing-gbenchmark_main)
+target_link_libraries(cpp-testing-gbenchmark_main PUBLIC
+ contrib-libs-cxxsupp
+ yutil
+ contrib-libs-benchmark
+ cpp-testing-hook
+)
+target_sources(cpp-testing-gbenchmark_main PRIVATE
+ ${CMAKE_SOURCE_DIR}/library/cpp/testing/gbenchmark_main/main.cpp
+)
diff --git a/library/cpp/testing/gbenchmark_main/CMakeLists.linux-aarch64.txt b/library/cpp/testing/gbenchmark_main/CMakeLists.linux-aarch64.txt
new file mode 100644
index 00000000000..66a59ee4146
--- /dev/null
+++ b/library/cpp/testing/gbenchmark_main/CMakeLists.linux-aarch64.txt
@@ -0,0 +1,20 @@
+
+# This file was generated by the build system used internally in the Yandex monorepo.
+# Only simple modifications are allowed (adding source-files to targets, adding simple properties
+# like target_include_directories). These modifications will be ported to original
+# ya.make files by maintainers. Any complex modifications which can't be ported back to the
+# original buildsystem will not be accepted.
+
+
+
+add_library(cpp-testing-gbenchmark_main)
+target_link_libraries(cpp-testing-gbenchmark_main PUBLIC
+ contrib-libs-linux-headers
+ contrib-libs-cxxsupp
+ yutil
+ contrib-libs-benchmark
+ cpp-testing-hook
+)
+target_sources(cpp-testing-gbenchmark_main PRIVATE
+ ${CMAKE_SOURCE_DIR}/library/cpp/testing/gbenchmark_main/main.cpp
+)
diff --git a/library/cpp/testing/gbenchmark_main/CMakeLists.linux-x86_64.txt b/library/cpp/testing/gbenchmark_main/CMakeLists.linux-x86_64.txt
new file mode 100644
index 00000000000..66a59ee4146
--- /dev/null
+++ b/library/cpp/testing/gbenchmark_main/CMakeLists.linux-x86_64.txt
@@ -0,0 +1,20 @@
+
+# This file was generated by the build system used internally in the Yandex monorepo.
+# Only simple modifications are allowed (adding source-files to targets, adding simple properties
+# like target_include_directories). These modifications will be ported to original
+# ya.make files by maintainers. Any complex modifications which can't be ported back to the
+# original buildsystem will not be accepted.
+
+
+
+add_library(cpp-testing-gbenchmark_main)
+target_link_libraries(cpp-testing-gbenchmark_main PUBLIC
+ contrib-libs-linux-headers
+ contrib-libs-cxxsupp
+ yutil
+ contrib-libs-benchmark
+ cpp-testing-hook
+)
+target_sources(cpp-testing-gbenchmark_main PRIVATE
+ ${CMAKE_SOURCE_DIR}/library/cpp/testing/gbenchmark_main/main.cpp
+)
diff --git a/library/cpp/testing/gbenchmark_main/CMakeLists.txt b/library/cpp/testing/gbenchmark_main/CMakeLists.txt
new file mode 100644
index 00000000000..f8b31df0c11
--- /dev/null
+++ b/library/cpp/testing/gbenchmark_main/CMakeLists.txt
@@ -0,0 +1,17 @@
+
+# This file was generated by the build system used internally in the Yandex monorepo.
+# Only simple modifications are allowed (adding source-files to targets, adding simple properties
+# like target_include_directories). These modifications will be ported to original
+# ya.make files by maintainers. Any complex modifications which can't be ported back to the
+# original buildsystem will not be accepted.
+
+
+if (CMAKE_SYSTEM_NAME STREQUAL "Linux" AND CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64" AND NOT HAVE_CUDA)
+ include(CMakeLists.linux-aarch64.txt)
+elseif (CMAKE_SYSTEM_NAME STREQUAL "Darwin" AND CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
+ include(CMakeLists.darwin-x86_64.txt)
+elseif (WIN32 AND CMAKE_SYSTEM_PROCESSOR STREQUAL "AMD64" AND NOT HAVE_CUDA)
+ include(CMakeLists.windows-x86_64.txt)
+elseif (CMAKE_SYSTEM_NAME STREQUAL "Linux" AND CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" AND NOT HAVE_CUDA)
+ include(CMakeLists.linux-x86_64.txt)
+endif()
diff --git a/library/cpp/testing/gbenchmark_main/CMakeLists.windows-x86_64.txt b/library/cpp/testing/gbenchmark_main/CMakeLists.windows-x86_64.txt
new file mode 100644
index 00000000000..3253a09a82e
--- /dev/null
+++ b/library/cpp/testing/gbenchmark_main/CMakeLists.windows-x86_64.txt
@@ -0,0 +1,19 @@
+
+# This file was generated by the build system used internally in the Yandex monorepo.
+# Only simple modifications are allowed (adding source-files to targets, adding simple properties
+# like target_include_directories). These modifications will be ported to original
+# ya.make files by maintainers. Any complex modifications which can't be ported back to the
+# original buildsystem will not be accepted.
+
+
+
+add_library(cpp-testing-gbenchmark_main)
+target_link_libraries(cpp-testing-gbenchmark_main PUBLIC
+ contrib-libs-cxxsupp
+ yutil
+ contrib-libs-benchmark
+ cpp-testing-hook
+)
+target_sources(cpp-testing-gbenchmark_main PRIVATE
+ ${CMAKE_SOURCE_DIR}/library/cpp/testing/gbenchmark_main/main.cpp
+)
diff --git a/ydb/core/tablet_flat/CMakeLists.darwin-x86_64.txt b/ydb/core/tablet_flat/CMakeLists.darwin-x86_64.txt
index a7e948070e9..1efa4f738a7 100644
--- a/ydb/core/tablet_flat/CMakeLists.darwin-x86_64.txt
+++ b/ydb/core/tablet_flat/CMakeLists.darwin-x86_64.txt
@@ -6,6 +6,7 @@
# original buildsystem will not be accepted.
+add_subdirectory(benchmark)
add_subdirectory(protos)
add_subdirectory(test)
add_subdirectory(ut)
diff --git a/ydb/core/tablet_flat/CMakeLists.linux-aarch64.txt b/ydb/core/tablet_flat/CMakeLists.linux-aarch64.txt
index e4ade3f8a9b..e7ee474cc48 100644
--- a/ydb/core/tablet_flat/CMakeLists.linux-aarch64.txt
+++ b/ydb/core/tablet_flat/CMakeLists.linux-aarch64.txt
@@ -6,6 +6,7 @@
# original buildsystem will not be accepted.
+add_subdirectory(benchmark)
add_subdirectory(protos)
add_subdirectory(test)
add_subdirectory(ut)
diff --git a/ydb/core/tablet_flat/CMakeLists.linux-x86_64.txt b/ydb/core/tablet_flat/CMakeLists.linux-x86_64.txt
index e4ade3f8a9b..e7ee474cc48 100644
--- a/ydb/core/tablet_flat/CMakeLists.linux-x86_64.txt
+++ b/ydb/core/tablet_flat/CMakeLists.linux-x86_64.txt
@@ -6,6 +6,7 @@
# original buildsystem will not be accepted.
+add_subdirectory(benchmark)
add_subdirectory(protos)
add_subdirectory(test)
add_subdirectory(ut)
diff --git a/ydb/core/tablet_flat/CMakeLists.windows-x86_64.txt b/ydb/core/tablet_flat/CMakeLists.windows-x86_64.txt
index a7e948070e9..1efa4f738a7 100644
--- a/ydb/core/tablet_flat/CMakeLists.windows-x86_64.txt
+++ b/ydb/core/tablet_flat/CMakeLists.windows-x86_64.txt
@@ -6,6 +6,7 @@
# original buildsystem will not be accepted.
+add_subdirectory(benchmark)
add_subdirectory(protos)
add_subdirectory(test)
add_subdirectory(ut)
diff --git a/ydb/core/tablet_flat/benchmark/CMakeLists.darwin-x86_64.txt b/ydb/core/tablet_flat/benchmark/CMakeLists.darwin-x86_64.txt
new file mode 100644
index 00000000000..5f4b74bc0c7
--- /dev/null
+++ b/ydb/core/tablet_flat/benchmark/CMakeLists.darwin-x86_64.txt
@@ -0,0 +1,55 @@
+
+# This file was generated by the build system used internally in the Yandex monorepo.
+# Only simple modifications are allowed (adding source-files to targets, adding simple properties
+# like target_include_directories). These modifications will be ported to original
+# ya.make files by maintainers. Any complex modifications which can't be ported back to the
+# original buildsystem will not be accepted.
+
+
+
+add_executable(benchmark)
+target_link_libraries(benchmark PUBLIC
+ contrib-libs-cxxsupp
+ yutil
+ library-cpp-cpuid_check
+ cpp-testing-gbenchmark_main
+ library-cpp-resource
+ ydb-core-scheme
+ test-libs-exec
+ test-libs-table
+ core-testlib-default
+)
+target_link_options(benchmark PRIVATE
+ -Wl,-platform_version,macos,11.0,11.0
+ -fPIC
+ -fPIC
+ -framework
+ CoreFoundation
+)
+target_sources(benchmark PRIVATE
+ ${CMAKE_SOURCE_DIR}/ydb/core/tablet_flat/benchmark/b_charge.cpp
+)
+add_test(
+ NAME
+ benchmark
+ COMMAND
+ benchmark
+)
+set_property(
+ TEST
+ benchmark
+ PROPERTY
+ LABELS
+ SMALL
+)
+set_property(
+ TEST
+ benchmark
+ PROPERTY
+ PROCESSORS
+ 1
+)
+target_allocator(benchmark
+ system_allocator
+)
+vcs_info(benchmark)
diff --git a/ydb/core/tablet_flat/benchmark/CMakeLists.linux-aarch64.txt b/ydb/core/tablet_flat/benchmark/CMakeLists.linux-aarch64.txt
new file mode 100644
index 00000000000..d7ee4076b3b
--- /dev/null
+++ b/ydb/core/tablet_flat/benchmark/CMakeLists.linux-aarch64.txt
@@ -0,0 +1,58 @@
+
+# This file was generated by the build system used internally in the Yandex monorepo.
+# Only simple modifications are allowed (adding source-files to targets, adding simple properties
+# like target_include_directories). These modifications will be ported to original
+# ya.make files by maintainers. Any complex modifications which can't be ported back to the
+# original buildsystem will not be accepted.
+
+
+
+add_executable(benchmark)
+target_link_libraries(benchmark PUBLIC
+ contrib-libs-linux-headers
+ contrib-libs-cxxsupp
+ yutil
+ cpp-testing-gbenchmark_main
+ library-cpp-resource
+ ydb-core-scheme
+ test-libs-exec
+ test-libs-table
+ core-testlib-default
+)
+target_link_options(benchmark PRIVATE
+ -ldl
+ -lrt
+ -Wl,--no-as-needed
+ -fPIC
+ -fPIC
+ -lpthread
+ -lrt
+ -ldl
+)
+target_sources(benchmark PRIVATE
+ ${CMAKE_SOURCE_DIR}/ydb/core/tablet_flat/benchmark/b_charge.cpp
+)
+add_test(
+ NAME
+ benchmark
+ COMMAND
+ benchmark
+)
+set_property(
+ TEST
+ benchmark
+ PROPERTY
+ LABELS
+ SMALL
+)
+set_property(
+ TEST
+ benchmark
+ PROPERTY
+ PROCESSORS
+ 1
+)
+target_allocator(benchmark
+ cpp-malloc-jemalloc
+)
+vcs_info(benchmark)
diff --git a/ydb/core/tablet_flat/benchmark/CMakeLists.linux-x86_64.txt b/ydb/core/tablet_flat/benchmark/CMakeLists.linux-x86_64.txt
new file mode 100644
index 00000000000..0f81eddc3b5
--- /dev/null
+++ b/ydb/core/tablet_flat/benchmark/CMakeLists.linux-x86_64.txt
@@ -0,0 +1,60 @@
+
+# This file was generated by the build system used internally in the Yandex monorepo.
+# Only simple modifications are allowed (adding source-files to targets, adding simple properties
+# like target_include_directories). These modifications will be ported to original
+# ya.make files by maintainers. Any complex modifications which can't be ported back to the
+# original buildsystem will not be accepted.
+
+
+
+add_executable(benchmark)
+target_link_libraries(benchmark PUBLIC
+ contrib-libs-linux-headers
+ contrib-libs-cxxsupp
+ yutil
+ library-cpp-cpuid_check
+ cpp-testing-gbenchmark_main
+ library-cpp-resource
+ ydb-core-scheme
+ test-libs-exec
+ test-libs-table
+ core-testlib-default
+)
+target_link_options(benchmark PRIVATE
+ -ldl
+ -lrt
+ -Wl,--no-as-needed
+ -fPIC
+ -fPIC
+ -lpthread
+ -lrt
+ -ldl
+)
+target_sources(benchmark PRIVATE
+ ${CMAKE_SOURCE_DIR}/ydb/core/tablet_flat/benchmark/b_charge.cpp
+)
+add_test(
+ NAME
+ benchmark
+ COMMAND
+ benchmark
+)
+set_property(
+ TEST
+ benchmark
+ PROPERTY
+ LABELS
+ SMALL
+)
+set_property(
+ TEST
+ benchmark
+ PROPERTY
+ PROCESSORS
+ 1
+)
+target_allocator(benchmark
+ cpp-malloc-tcmalloc
+ libs-tcmalloc-no_percpu_cache
+)
+vcs_info(benchmark)
diff --git a/ydb/core/tablet_flat/benchmark/CMakeLists.txt b/ydb/core/tablet_flat/benchmark/CMakeLists.txt
new file mode 100644
index 00000000000..f8b31df0c11
--- /dev/null
+++ b/ydb/core/tablet_flat/benchmark/CMakeLists.txt
@@ -0,0 +1,17 @@
+
+# This file was generated by the build system used internally in the Yandex monorepo.
+# Only simple modifications are allowed (adding source-files to targets, adding simple properties
+# like target_include_directories). These modifications will be ported to original
+# ya.make files by maintainers. Any complex modifications which can't be ported back to the
+# original buildsystem will not be accepted.
+
+
+if (CMAKE_SYSTEM_NAME STREQUAL "Linux" AND CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64" AND NOT HAVE_CUDA)
+ include(CMakeLists.linux-aarch64.txt)
+elseif (CMAKE_SYSTEM_NAME STREQUAL "Darwin" AND CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
+ include(CMakeLists.darwin-x86_64.txt)
+elseif (WIN32 AND CMAKE_SYSTEM_PROCESSOR STREQUAL "AMD64" AND NOT HAVE_CUDA)
+ include(CMakeLists.windows-x86_64.txt)
+elseif (CMAKE_SYSTEM_NAME STREQUAL "Linux" AND CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" AND NOT HAVE_CUDA)
+ include(CMakeLists.linux-x86_64.txt)
+endif()
diff --git a/ydb/core/tablet_flat/benchmark/CMakeLists.windows-x86_64.txt b/ydb/core/tablet_flat/benchmark/CMakeLists.windows-x86_64.txt
new file mode 100644
index 00000000000..dba5dc0e86c
--- /dev/null
+++ b/ydb/core/tablet_flat/benchmark/CMakeLists.windows-x86_64.txt
@@ -0,0 +1,48 @@
+
+# This file was generated by the build system used internally in the Yandex monorepo.
+# Only simple modifications are allowed (adding source-files to targets, adding simple properties
+# like target_include_directories). These modifications will be ported to original
+# ya.make files by maintainers. Any complex modifications which can't be ported back to the
+# original buildsystem will not be accepted.
+
+
+
+add_executable(benchmark)
+target_link_libraries(benchmark PUBLIC
+ contrib-libs-cxxsupp
+ yutil
+ library-cpp-cpuid_check
+ cpp-testing-gbenchmark_main
+ library-cpp-resource
+ ydb-core-scheme
+ test-libs-exec
+ test-libs-table
+ core-testlib-default
+)
+target_sources(benchmark PRIVATE
+ ${CMAKE_SOURCE_DIR}/ydb/core/tablet_flat/benchmark/b_charge.cpp
+)
+add_test(
+ NAME
+ benchmark
+ COMMAND
+ benchmark
+)
+set_property(
+ TEST
+ benchmark
+ PROPERTY
+ LABELS
+ SMALL
+)
+set_property(
+ TEST
+ benchmark
+ PROPERTY
+ PROCESSORS
+ 1
+)
+target_allocator(benchmark
+ system_allocator
+)
+vcs_info(benchmark)
diff --git a/ydb/core/tablet_flat/benchmark/b_charge.cpp b/ydb/core/tablet_flat/benchmark/b_charge.cpp
new file mode 100644
index 00000000000..31e69c564e7
--- /dev/null
+++ b/ydb/core/tablet_flat/benchmark/b_charge.cpp
@@ -0,0 +1,172 @@
+#include <benchmark/benchmark.h>
+#include <random>
+
+#include <ydb/core/tablet_flat/flat_row_celled.h>
+#include <ydb/core/tablet_flat/flat_part_charge.h>
+#include <ydb/core/tablet_flat/test/libs/rows/cook.h>
+#include <ydb/core/tablet_flat/test/libs/rows/tool.h>
+#include <ydb/core/tablet_flat/test/libs/table/model/large.h>
+#include <ydb/core/tablet_flat/test/libs/table/test_writer.h>
+#include <ydb/core/tablet_flat/test/libs/table/test_envs.h>
+#include <ydb/core/tablet_flat/test/libs/table/wrap_part.h>
+#include <ydb/core/tablet_flat/test/libs/table/test_steps.h>
+
+#include <library/cpp/testing/unittest/registar.h>
+
+namespace NKikimr {
+namespace NTable {
+
+namespace {
+ const NTest::TMass Mass(new NTest::TModelStd(true), 2*1000);
+
+ struct TTouchEnv : public NTest::TTestEnv {
+ TTouchEnv(bool fail) : Fail(fail) { }
+
+ const TSharedData* TryGetPage(const TPart *part, TPageId id, TGroupId groupId) override
+ {
+ TouchedCount++;
+ return Fail ? nullptr : NTest::TTestEnv::TryGetPage(part, id, groupId);
+ }
+
+ const bool Fail = false;
+ ui64 TouchedCount = 0;
+ };
+
+ struct TCooker {
+ TCooker(const TRowScheme &scheme)
+ : Tool(scheme)
+ , Writer(new TPartScheme(scheme.Cols), { }, NPage::TGroupId(0))
+ {
+
+ }
+
+ TCooker& Add(const NTest::TRow &row, ui64 offset, ui32 page)
+ {
+ const TCelled key(Tool.LookupKey(row), *Tool.Scheme.Keys, false);
+
+ return Writer.Add(key, offset, page), *this;
+ }
+
+ TSharedData Flush()
+ {
+ return Writer.Flush();
+ }
+
+ private:
+ const NTest::TRowTool Tool;
+ NPage::TIndexWriter Writer;
+ };
+
+ struct TModel : public benchmark::Fixture {
+ using TGroupId = NPage::TGroupId;
+
+ TModel()
+ : Tool(*Mass.Model->Scheme)
+ {
+ auto pages = Eggs.At(0)->Index->End() - Eggs.At(0)->Index->Begin();
+
+ Y_VERIFY(pages > 120);
+ }
+
+ static NTest::TPartEggs MakeEggs() noexcept
+ {
+ NPage::TConf conf{ true, 8192 };
+
+ auto groups = Mass.Model->Scheme->Families.size();
+ for (size_t group : xrange(groups)) {
+ conf.Group(group).PageRows = 10;
+ }
+ conf.Group(1).PageRows = 5;
+ conf.Group(2).PageRows = 2;
+
+ NTest::TPartCook cook(Mass.Model->Scheme, conf);
+
+ for (auto seq: xrange(Mass.Saved.Size())) {
+ // fill with random keys
+ if (seq % 3 != 0) cook.Add(Mass.Saved[seq]);
+ }
+
+ return cook.Finish();
+ }
+
+ void SetUp(const ::benchmark::State& state)
+ {
+ bool fail = state.range(1);
+ ui32 groups = state.range(2);
+
+ Env = MakeHolder<TTouchEnv>(fail);
+
+ const auto &keyDefaults = *Tool.Scheme.Keys;
+
+ Run = MakeHolder<TRun>(keyDefaults);
+
+ auto part = Eggs.Lone();
+ for (auto& slice : *part->Slices) {
+ Run->Insert(part, slice);
+ }
+
+ Tags = TVector<TTag>();
+ for (auto c : Mass.Model->Scheme->Cols) {
+ if (c.Group <= groups) {
+ Tags.push_back(c.Tag);
+ }
+ }
+ }
+
+ void TearDown(const ::benchmark::State& state) {
+ (void)state;
+ Run.Reset();
+ Env.Reset();
+ }
+
+ const NTest::TRowTool Tool;
+ const NTest::TPartEggs Eggs = MakeEggs();
+ THolder<TTouchEnv> Env;
+ THolder<TRun> Run;
+ TVector<TTag> Tags;
+ };
+}
+
+BENCHMARK_DEFINE_F(TModel, PrechargeByKeys)(benchmark::State& state) {
+ ui64 items = state.range(0);
+
+ const auto &keyDefaults = *Tool.Scheme.Keys;
+
+ ui32 it = 0;
+ for (auto _ : state) {
+ ui32 lower = ++it % 50;
+ ui32 upper = lower + items;
+
+ const auto from = Tool.KeyCells(Mass.Saved[lower]);
+ const auto to = Tool.KeyCells(Mass.Saved[upper]);
+
+ TCharge::Range(Env.Get(), from, to, *Run.Get(), keyDefaults, Tags, items, Max<ui64>());
+ }
+
+ state.counters["Touched"] = Env->TouchedCount;
+}
+
+BENCHMARK_DEFINE_F(TModel, PrechargeByRows)(benchmark::State& state) {
+ ui64 items = state.range(0);
+
+ ui32 it = 0;
+ for (auto _ : state) {
+ ui32 lower = ++it % 50;
+ ui32 upper = lower + items;
+
+ TCharge(Env.Get(), *(Run.Get())->begin()->Part, Tags, false).Do(lower, upper, items, Max<ui64>());
+ }
+
+ state.counters["Touched"] = Env->TouchedCount;
+}
+
+BENCHMARK_REGISTER_F(TModel, PrechargeByKeys)
+ ->ArgsProduct({/*items:*/ {0, 100, 1000}, /*fail:*/{0, 1}, /*groups:*/ {0, 1, 2}})
+ ->Unit(benchmark::kMicrosecond);
+
+BENCHMARK_REGISTER_F(TModel, PrechargeByRows)
+ ->ArgsProduct({/*items:*/ {0, 100, 1000}, /*fail:*/{0, 1}, /*groups:*/ {0, 1, 2}})
+ ->Unit(benchmark::kMicrosecond);
+
+}
+}