aboutsummaryrefslogtreecommitdiffstats
path: root/util/generic/benchmark
diff options
context:
space:
mode:
authorAnton Samokhvalov <pg83@yandex.ru>2022-02-10 16:45:15 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:45:15 +0300
commit72cb13b4aff9bc9cf22e49251bc8fd143f82538f (patch)
treeda2c34829458c7d4e74bdfbdf85dff449e9e7fb8 /util/generic/benchmark
parent778e51ba091dc39e7b7fcab2b9cf4dbedfb6f2b5 (diff)
downloadydb-72cb13b4aff9bc9cf22e49251bc8fd143f82538f.tar.gz
Restoring authorship annotation for Anton Samokhvalov <pg83@yandex.ru>. Commit 1 of 2.
Diffstat (limited to 'util/generic/benchmark')
-rw-r--r--util/generic/benchmark/cont_speed/main.cpp234
-rw-r--r--util/generic/benchmark/cont_speed/ya.make18
-rw-r--r--util/generic/benchmark/fastclp2/main.cpp6
-rw-r--r--util/generic/benchmark/rotate_bits/main.cpp4
-rw-r--r--util/generic/benchmark/singleton/f.cpp36
-rw-r--r--util/generic/benchmark/singleton/main.cpp106
-rw-r--r--util/generic/benchmark/singleton/ya.make16
-rw-r--r--util/generic/benchmark/smart_pointers/main.cpp26
-rw-r--r--util/generic/benchmark/smart_pointers/ya.make14
-rw-r--r--util/generic/benchmark/sort/main.cpp136
-rw-r--r--util/generic/benchmark/sort/ya.make14
-rw-r--r--util/generic/benchmark/string/benchmarks.h4
-rw-r--r--util/generic/benchmark/ya.make12
13 files changed, 313 insertions, 313 deletions
diff --git a/util/generic/benchmark/cont_speed/main.cpp b/util/generic/benchmark/cont_speed/main.cpp
index 01428c9974..072f3e3114 100644
--- a/util/generic/benchmark/cont_speed/main.cpp
+++ b/util/generic/benchmark/cont_speed/main.cpp
@@ -1,117 +1,117 @@
-#include <library/cpp/testing/benchmark/bench.h>
-
-#include <util/generic/xrange.h>
-#include <util/generic/string.h>
-#include <util/generic/vector.h>
-#include <util/generic/buffer.h>
-
-template <class C>
-Y_NO_INLINE void Run(const C& c) {
- for (size_t i = 0; i < c.size(); ++i) {
- Y_DO_NOT_OPTIMIZE_AWAY(c[i]);
- }
-}
-
-template <class C>
-void Do(size_t len, auto& iface) {
- C c(len, 0);
-
- for (auto i : xrange(iface.Iterations())) {
- Y_UNUSED(i);
- Run(c);
- }
-}
-
-Y_CPU_BENCHMARK(TVector10, iface) {
- Do<TVector<char>>(10, iface);
-}
-
-Y_CPU_BENCHMARK(TVector100, iface) {
- Do<TVector<char>>(100, iface);
-}
-
-Y_CPU_BENCHMARK(TVector1000, iface) {
- Do<TVector<char>>(1000, iface);
-}
-
-Y_CPU_BENCHMARK(TString10, iface) {
- Do<TString>(10, iface);
-}
-
-Y_CPU_BENCHMARK(TString100, iface) {
- Do<TString>(100, iface);
-}
-
-Y_CPU_BENCHMARK(TString1000, iface) {
- Do<TString>(1000, iface);
-}
-
-Y_CPU_BENCHMARK(StdString10, iface) {
- Do<std::string>(10, iface);
-}
-
-Y_CPU_BENCHMARK(StdString100, iface) {
- Do<std::string>(100, iface);
-}
-
-Y_CPU_BENCHMARK(StdString1000, iface) {
- Do<std::string>(1000, iface);
-}
-
-struct TBuf: public TBuffer {
- TBuf(size_t len, char v) {
- for (size_t i = 0; i < len; ++i) {
- Append(v);
- }
- }
-
- inline const auto& operator[](size_t i) const noexcept {
- return *(data() + i);
- }
-};
-
-Y_CPU_BENCHMARK(TBuffer10, iface) {
- Do<TBuf>(10, iface);
-}
-
-Y_CPU_BENCHMARK(TBuffer100, iface) {
- Do<TBuf>(100, iface);
-}
-
-Y_CPU_BENCHMARK(TBuffer1000, iface) {
- Do<TBuf>(1000, iface);
-}
-
-struct TArr {
- inline TArr(size_t len, char ch)
- : A(new char[len])
- , L(len)
- {
- for (size_t i = 0; i < L; ++i) {
- A[i] = ch;
- }
- }
-
- inline const auto& operator[](size_t i) const noexcept {
- return A[i];
- }
-
- inline size_t size() const noexcept {
- return L;
- }
-
- char* A;
- size_t L;
-};
-
-Y_CPU_BENCHMARK(Pointer10, iface) {
- Do<TArr>(10, iface);
-}
-
-Y_CPU_BENCHMARK(Pointer100, iface) {
- Do<TArr>(100, iface);
-}
-
-Y_CPU_BENCHMARK(Pointer1000, iface) {
- Do<TArr>(1000, iface);
-}
+#include <library/cpp/testing/benchmark/bench.h>
+
+#include <util/generic/xrange.h>
+#include <util/generic/string.h>
+#include <util/generic/vector.h>
+#include <util/generic/buffer.h>
+
+template <class C>
+Y_NO_INLINE void Run(const C& c) {
+ for (size_t i = 0; i < c.size(); ++i) {
+ Y_DO_NOT_OPTIMIZE_AWAY(c[i]);
+ }
+}
+
+template <class C>
+void Do(size_t len, auto& iface) {
+ C c(len, 0);
+
+ for (auto i : xrange(iface.Iterations())) {
+ Y_UNUSED(i);
+ Run(c);
+ }
+}
+
+Y_CPU_BENCHMARK(TVector10, iface) {
+ Do<TVector<char>>(10, iface);
+}
+
+Y_CPU_BENCHMARK(TVector100, iface) {
+ Do<TVector<char>>(100, iface);
+}
+
+Y_CPU_BENCHMARK(TVector1000, iface) {
+ Do<TVector<char>>(1000, iface);
+}
+
+Y_CPU_BENCHMARK(TString10, iface) {
+ Do<TString>(10, iface);
+}
+
+Y_CPU_BENCHMARK(TString100, iface) {
+ Do<TString>(100, iface);
+}
+
+Y_CPU_BENCHMARK(TString1000, iface) {
+ Do<TString>(1000, iface);
+}
+
+Y_CPU_BENCHMARK(StdString10, iface) {
+ Do<std::string>(10, iface);
+}
+
+Y_CPU_BENCHMARK(StdString100, iface) {
+ Do<std::string>(100, iface);
+}
+
+Y_CPU_BENCHMARK(StdString1000, iface) {
+ Do<std::string>(1000, iface);
+}
+
+struct TBuf: public TBuffer {
+ TBuf(size_t len, char v) {
+ for (size_t i = 0; i < len; ++i) {
+ Append(v);
+ }
+ }
+
+ inline const auto& operator[](size_t i) const noexcept {
+ return *(data() + i);
+ }
+};
+
+Y_CPU_BENCHMARK(TBuffer10, iface) {
+ Do<TBuf>(10, iface);
+}
+
+Y_CPU_BENCHMARK(TBuffer100, iface) {
+ Do<TBuf>(100, iface);
+}
+
+Y_CPU_BENCHMARK(TBuffer1000, iface) {
+ Do<TBuf>(1000, iface);
+}
+
+struct TArr {
+ inline TArr(size_t len, char ch)
+ : A(new char[len])
+ , L(len)
+ {
+ for (size_t i = 0; i < L; ++i) {
+ A[i] = ch;
+ }
+ }
+
+ inline const auto& operator[](size_t i) const noexcept {
+ return A[i];
+ }
+
+ inline size_t size() const noexcept {
+ return L;
+ }
+
+ char* A;
+ size_t L;
+};
+
+Y_CPU_BENCHMARK(Pointer10, iface) {
+ Do<TArr>(10, iface);
+}
+
+Y_CPU_BENCHMARK(Pointer100, iface) {
+ Do<TArr>(100, iface);
+}
+
+Y_CPU_BENCHMARK(Pointer1000, iface) {
+ Do<TArr>(1000, iface);
+}
diff --git a/util/generic/benchmark/cont_speed/ya.make b/util/generic/benchmark/cont_speed/ya.make
index 6ff3fe767c..67b3ae0bbe 100644
--- a/util/generic/benchmark/cont_speed/ya.make
+++ b/util/generic/benchmark/cont_speed/ya.make
@@ -1,9 +1,9 @@
-Y_BENCHMARK()
-
-OWNER(g:util)
-
-SRCS(
- main.cpp
-)
-
-END()
+Y_BENCHMARK()
+
+OWNER(g:util)
+
+SRCS(
+ main.cpp
+)
+
+END()
diff --git a/util/generic/benchmark/fastclp2/main.cpp b/util/generic/benchmark/fastclp2/main.cpp
index 49277db077..12578216e2 100644
--- a/util/generic/benchmark/fastclp2/main.cpp
+++ b/util/generic/benchmark/fastclp2/main.cpp
@@ -11,8 +11,8 @@ namespace {
template <typename T, size_t N>
struct TExamplesHolder {
TExamplesHolder()
- : Examples(N)
- {
+ : Examples(N)
+ {
TFastRng<ui64> prng{42u * sizeof(T) * N};
for (auto& x : Examples) {
x = prng();
@@ -23,7 +23,7 @@ namespace {
};
}
-#define DEFINE_BENCHMARK(type, count) \
+#define DEFINE_BENCHMARK(type, count) \
Y_CPU_BENCHMARK(FastClp2_##type##_##count, iface) { \
const auto& examples = Default<TExamplesHolder<type, count>>().Examples; \
for (const auto i : xrange(iface.Iterations())) { \
diff --git a/util/generic/benchmark/rotate_bits/main.cpp b/util/generic/benchmark/rotate_bits/main.cpp
index 057edbe864..003cd29672 100644
--- a/util/generic/benchmark/rotate_bits/main.cpp
+++ b/util/generic/benchmark/rotate_bits/main.cpp
@@ -16,8 +16,8 @@ namespace {
template <typename T, size_t N>
struct TExamplesHolder {
TExamplesHolder()
- : Examples(N)
- {
+ : Examples(N)
+ {
TFastRng<ui64> prng{42u * sizeof(T) * N};
for (auto& e : Examples) {
e.Value = prng();
diff --git a/util/generic/benchmark/singleton/f.cpp b/util/generic/benchmark/singleton/f.cpp
index bf6da53d9c..ada8c9f60a 100644
--- a/util/generic/benchmark/singleton/f.cpp
+++ b/util/generic/benchmark/singleton/f.cpp
@@ -1,18 +1,18 @@
-#include <util/generic/singleton.h>
-
-struct X {
- inline X() {
- }
-
- char Buf[100];
-};
-
-char& FF1() noexcept {
- static X x;
-
- return x.Buf[0];
-}
-
-char& FF2() noexcept {
- return Singleton<X>()->Buf[0];
-}
+#include <util/generic/singleton.h>
+
+struct X {
+ inline X() {
+ }
+
+ char Buf[100];
+};
+
+char& FF1() noexcept {
+ static X x;
+
+ return x.Buf[0];
+}
+
+char& FF2() noexcept {
+ return Singleton<X>()->Buf[0];
+}
diff --git a/util/generic/benchmark/singleton/main.cpp b/util/generic/benchmark/singleton/main.cpp
index 2b06bd371d..9bceca1b07 100644
--- a/util/generic/benchmark/singleton/main.cpp
+++ b/util/generic/benchmark/singleton/main.cpp
@@ -1,54 +1,54 @@
#include <library/cpp/testing/benchmark/bench.h>
-
-#include <util/generic/singleton.h>
-#include <util/generic/xrange.h>
-
-char& FF1() noexcept;
-char& FF2() noexcept;
-
-namespace {
- struct X {
- inline X() {
- }
-
- char Buf[100];
- };
-
- inline X& F1() noexcept {
- static X x;
-
- return x;
- }
-
- inline X& F2() noexcept {
- return *Singleton<X>();
- }
-}
-
-Y_CPU_BENCHMARK(MagicStatic, iface) {
- for (const auto i : xrange(iface.Iterations())) {
- Y_UNUSED(i);
- Y_DO_NOT_OPTIMIZE_AWAY(F1().Buf);
- }
-}
-
-Y_CPU_BENCHMARK(Singleton, iface) {
- for (const auto i : xrange(iface.Iterations())) {
- Y_UNUSED(i);
- Y_DO_NOT_OPTIMIZE_AWAY(F2().Buf);
- }
-}
-
-Y_CPU_BENCHMARK(MagicStaticNI, iface) {
- for (const auto i : xrange(iface.Iterations())) {
- Y_UNUSED(i);
- Y_DO_NOT_OPTIMIZE_AWAY(FF1());
- }
-}
-
-Y_CPU_BENCHMARK(SingletonNI, iface) {
- for (const auto i : xrange(iface.Iterations())) {
- Y_UNUSED(i);
- Y_DO_NOT_OPTIMIZE_AWAY(FF2());
- }
-}
+
+#include <util/generic/singleton.h>
+#include <util/generic/xrange.h>
+
+char& FF1() noexcept;
+char& FF2() noexcept;
+
+namespace {
+ struct X {
+ inline X() {
+ }
+
+ char Buf[100];
+ };
+
+ inline X& F1() noexcept {
+ static X x;
+
+ return x;
+ }
+
+ inline X& F2() noexcept {
+ return *Singleton<X>();
+ }
+}
+
+Y_CPU_BENCHMARK(MagicStatic, iface) {
+ for (const auto i : xrange(iface.Iterations())) {
+ Y_UNUSED(i);
+ Y_DO_NOT_OPTIMIZE_AWAY(F1().Buf);
+ }
+}
+
+Y_CPU_BENCHMARK(Singleton, iface) {
+ for (const auto i : xrange(iface.Iterations())) {
+ Y_UNUSED(i);
+ Y_DO_NOT_OPTIMIZE_AWAY(F2().Buf);
+ }
+}
+
+Y_CPU_BENCHMARK(MagicStaticNI, iface) {
+ for (const auto i : xrange(iface.Iterations())) {
+ Y_UNUSED(i);
+ Y_DO_NOT_OPTIMIZE_AWAY(FF1());
+ }
+}
+
+Y_CPU_BENCHMARK(SingletonNI, iface) {
+ for (const auto i : xrange(iface.Iterations())) {
+ Y_UNUSED(i);
+ Y_DO_NOT_OPTIMIZE_AWAY(FF2());
+ }
+}
diff --git a/util/generic/benchmark/singleton/ya.make b/util/generic/benchmark/singleton/ya.make
index 12d3d316c8..d34e0863fa 100644
--- a/util/generic/benchmark/singleton/ya.make
+++ b/util/generic/benchmark/singleton/ya.make
@@ -1,11 +1,11 @@
Y_BENCHMARK()
-
+
OWNER(g:util)
SUBSCRIBER(g:util-subscribers)
-
-SRCS(
- f.cpp
- main.cpp
-)
-
-END()
+
+SRCS(
+ f.cpp
+ main.cpp
+)
+
+END()
diff --git a/util/generic/benchmark/smart_pointers/main.cpp b/util/generic/benchmark/smart_pointers/main.cpp
index 92c2f923bb..aa04601807 100644
--- a/util/generic/benchmark/smart_pointers/main.cpp
+++ b/util/generic/benchmark/smart_pointers/main.cpp
@@ -1,14 +1,14 @@
#include <library/cpp/testing/benchmark/bench.h>
-
-#include <util/generic/ptr.h>
-#include <util/generic/xrange.h>
-
-struct X: public TAtomicRefCount<X> {
-};
-
-Y_CPU_BENCHMARK(SimplePtrConstruct, iface) {
- for (const auto i : xrange(iface.Iterations())) {
- Y_UNUSED(i);
- Y_DO_NOT_OPTIMIZE_AWAY(TSimpleIntrusivePtr<X>());
- }
-}
+
+#include <util/generic/ptr.h>
+#include <util/generic/xrange.h>
+
+struct X: public TAtomicRefCount<X> {
+};
+
+Y_CPU_BENCHMARK(SimplePtrConstruct, iface) {
+ for (const auto i : xrange(iface.Iterations())) {
+ Y_UNUSED(i);
+ Y_DO_NOT_OPTIMIZE_AWAY(TSimpleIntrusivePtr<X>());
+ }
+}
diff --git a/util/generic/benchmark/smart_pointers/ya.make b/util/generic/benchmark/smart_pointers/ya.make
index 7059abc3a4..bd830bbe1d 100644
--- a/util/generic/benchmark/smart_pointers/ya.make
+++ b/util/generic/benchmark/smart_pointers/ya.make
@@ -1,10 +1,10 @@
Y_BENCHMARK()
-
+
OWNER(g:util)
SUBSCRIBER(g:util-subscribers)
-
-SRCS(
- main.cpp
-)
-
-END()
+
+SRCS(
+ main.cpp
+)
+
+END()
diff --git a/util/generic/benchmark/sort/main.cpp b/util/generic/benchmark/sort/main.cpp
index d58f491f4d..48fbd2052a 100644
--- a/util/generic/benchmark/sort/main.cpp
+++ b/util/generic/benchmark/sort/main.cpp
@@ -1,77 +1,77 @@
#include <library/cpp/testing/benchmark/bench.h>
-
-#include <util/generic/algorithm.h>
-#include <util/generic/vector.h>
-#include <util/generic/xrange.h>
-
-Y_CPU_BENCHMARK(Sort1, iface) {
+
+#include <util/generic/algorithm.h>
+#include <util/generic/vector.h>
+#include <util/generic/xrange.h>
+
+Y_CPU_BENCHMARK(Sort1, iface) {
TVector<int> x = {1};
-
- for (const auto i : xrange(iface.Iterations())) {
- Y_UNUSED(i);
- Sort(x);
- }
-}
-
-Y_CPU_BENCHMARK(Sort2, iface) {
+
+ for (const auto i : xrange(iface.Iterations())) {
+ Y_UNUSED(i);
+ Sort(x);
+ }
+}
+
+Y_CPU_BENCHMARK(Sort2, iface) {
TVector<int> x = {2, 1};
-
- for (const auto i : xrange(iface.Iterations())) {
- Y_UNUSED(i);
- Sort(x);
- }
-}
-
-Y_CPU_BENCHMARK(Sort4, iface) {
+
+ for (const auto i : xrange(iface.Iterations())) {
+ Y_UNUSED(i);
+ Sort(x);
+ }
+}
+
+Y_CPU_BENCHMARK(Sort4, iface) {
TVector<int> x = {4, 3, 2, 1};
-
- for (const auto i : xrange(iface.Iterations())) {
- Y_UNUSED(i);
- Sort(x);
- }
-}
-
-Y_CPU_BENCHMARK(Sort16, iface) {
+
+ for (const auto i : xrange(iface.Iterations())) {
+ Y_UNUSED(i);
+ Sort(x);
+ }
+}
+
+Y_CPU_BENCHMARK(Sort16, iface) {
TVector<int> x = {16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1};
-
- for (const auto i : xrange(iface.Iterations())) {
- Y_UNUSED(i);
- Sort(x);
- }
-}
-
-Y_CPU_BENCHMARK(StableSort1, iface) {
+
+ for (const auto i : xrange(iface.Iterations())) {
+ Y_UNUSED(i);
+ Sort(x);
+ }
+}
+
+Y_CPU_BENCHMARK(StableSort1, iface) {
TVector<int> x = {1};
-
- for (const auto i : xrange(iface.Iterations())) {
- Y_UNUSED(i);
- StableSort(x);
- }
-}
-
-Y_CPU_BENCHMARK(StableSort2, iface) {
+
+ for (const auto i : xrange(iface.Iterations())) {
+ Y_UNUSED(i);
+ StableSort(x);
+ }
+}
+
+Y_CPU_BENCHMARK(StableSort2, iface) {
TVector<int> x = {2, 1};
-
- for (const auto i : xrange(iface.Iterations())) {
- Y_UNUSED(i);
- StableSort(x);
- }
-}
-
-Y_CPU_BENCHMARK(StableSort4, iface) {
+
+ for (const auto i : xrange(iface.Iterations())) {
+ Y_UNUSED(i);
+ StableSort(x);
+ }
+}
+
+Y_CPU_BENCHMARK(StableSort4, iface) {
TVector<int> x = {4, 3, 2, 1};
-
- for (const auto i : xrange(iface.Iterations())) {
- Y_UNUSED(i);
- StableSort(x);
- }
-}
-
-Y_CPU_BENCHMARK(StableSort16, iface) {
+
+ for (const auto i : xrange(iface.Iterations())) {
+ Y_UNUSED(i);
+ StableSort(x);
+ }
+}
+
+Y_CPU_BENCHMARK(StableSort16, iface) {
TVector<int> x = {16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1};
-
- for (const auto i : xrange(iface.Iterations())) {
- Y_UNUSED(i);
- StableSort(x);
- }
-}
+
+ for (const auto i : xrange(iface.Iterations())) {
+ Y_UNUSED(i);
+ StableSort(x);
+ }
+}
diff --git a/util/generic/benchmark/sort/ya.make b/util/generic/benchmark/sort/ya.make
index 7059abc3a4..bd830bbe1d 100644
--- a/util/generic/benchmark/sort/ya.make
+++ b/util/generic/benchmark/sort/ya.make
@@ -1,10 +1,10 @@
Y_BENCHMARK()
-
+
OWNER(g:util)
SUBSCRIBER(g:util-subscribers)
-
-SRCS(
- main.cpp
-)
-
-END()
+
+SRCS(
+ main.cpp
+)
+
+END()
diff --git a/util/generic/benchmark/string/benchmarks.h b/util/generic/benchmark/string/benchmarks.h
index e347d7ff47..5420e75817 100644
--- a/util/generic/benchmark/string/benchmarks.h
+++ b/util/generic/benchmark/string/benchmarks.h
@@ -15,8 +15,8 @@ namespace {
const auto defaultString = TBenchmarkedClass();
const auto emptyString = TBenchmarkedClass("");
- const auto lengthOneString = TBenchmarkedClass("1");
- const auto length1KString = TBenchmarkedClass(1000, '1');
+ const auto lengthOneString = TBenchmarkedClass("1");
+ const auto length1KString = TBenchmarkedClass(1000, '1');
Y_CPU_PREFIXED_BENCHMARK(BENCHMARK_PREFIX, CreateDefault, iface) {
for (const auto i : xrange(iface.Iterations())) {
diff --git a/util/generic/benchmark/ya.make b/util/generic/benchmark/ya.make
index 635860a646..e477a02415 100644
--- a/util/generic/benchmark/ya.make
+++ b/util/generic/benchmark/ya.make
@@ -1,5 +1,5 @@
-OWNER(yazevnul g:util)
-
+OWNER(yazevnul g:util)
+
SUBSCRIBER(g:util-subscribers)
RECURSE(
@@ -10,10 +10,10 @@ RECURSE(
rotate_bits
rotate_bits/metrics
singleton
- smart_pointers
- sort
+ smart_pointers
+ sort
string
vector_count_ctor
- vector_count_ctor/metrics
- cont_speed
+ vector_count_ctor/metrics
+ cont_speed
)