diff options
author | monster <monster@ydb.tech> | 2022-07-07 14:41:37 +0300 |
---|---|---|
committer | monster <monster@ydb.tech> | 2022-07-07 14:41:37 +0300 |
commit | 06e5c21a835c0e923506c4ff27929f34e00761c2 (patch) | |
tree | 75efcbc6854ef9bd476eb8bf00cc5c900da436a2 /util/generic | |
parent | 03f024c4412e3aa613bb543cf1660176320ba8f4 (diff) | |
download | ydb-06e5c21a835c0e923506c4ff27929f34e00761c2.tar.gz |
fix ya.make
Diffstat (limited to 'util/generic')
20 files changed, 0 insertions, 1082 deletions
diff --git a/util/generic/benchmark/cont_speed/main.cpp b/util/generic/benchmark/cont_speed/main.cpp deleted file mode 100644 index 01428c99747..00000000000 --- a/util/generic/benchmark/cont_speed/main.cpp +++ /dev/null @@ -1,117 +0,0 @@ -#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/fastclp2/main.cpp b/util/generic/benchmark/fastclp2/main.cpp deleted file mode 100644 index 49277db077c..00000000000 --- a/util/generic/benchmark/fastclp2/main.cpp +++ /dev/null @@ -1,50 +0,0 @@ -#include <library/cpp/testing/benchmark/bench.h> - -#include <util/generic/bitops.h> -#include <util/generic/vector.h> -#include <util/generic/xrange.h> -#include <util/generic/singleton.h> - -#include <util/random/fast.h> - -namespace { - template <typename T, size_t N> - struct TExamplesHolder { - TExamplesHolder() - : Examples(N) - { - TFastRng<ui64> prng{42u * sizeof(T) * N}; - for (auto& x : Examples) { - x = prng(); - } - } - - TVector<T> Examples; - }; -} - -#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())) { \ - Y_UNUSED(i); \ - for (const auto e : examples) { \ - Y_DO_NOT_OPTIMIZE_AWAY(FastClp2(e)); \ - } \ - } \ - } - -DEFINE_BENCHMARK(ui8, 1) -DEFINE_BENCHMARK(ui8, 10) -DEFINE_BENCHMARK(ui8, 100) -DEFINE_BENCHMARK(ui16, 1) -DEFINE_BENCHMARK(ui16, 10) -DEFINE_BENCHMARK(ui16, 100) -DEFINE_BENCHMARK(ui32, 1) -DEFINE_BENCHMARK(ui32, 10) -DEFINE_BENCHMARK(ui32, 100) -DEFINE_BENCHMARK(ui64, 1) -DEFINE_BENCHMARK(ui64, 10) -DEFINE_BENCHMARK(ui64, 100) - -#undef DEFINE_BENCHMARKS diff --git a/util/generic/benchmark/fastclp2/metrics/main.py b/util/generic/benchmark/fastclp2/metrics/main.py deleted file mode 100644 index 5573c6a5d7f..00000000000 --- a/util/generic/benchmark/fastclp2/metrics/main.py +++ /dev/null @@ -1,5 +0,0 @@ -import yatest.common as yc - - -def test_export_metrics(metrics): - metrics.set_benchmark(yc.execute_benchmark('util/generic/benchmark/fastclp2/fastclp2', threads=8)) diff --git a/util/generic/benchmark/log2/main.cpp b/util/generic/benchmark/log2/main.cpp deleted file mode 100644 index 969f09a3090..00000000000 --- a/util/generic/benchmark/log2/main.cpp +++ /dev/null @@ -1,140 +0,0 @@ -#include <library/cpp/testing/benchmark/bench.h> - -#include <library/cpp/fast_log/fast_log.h> - -#include <util/generic/singleton.h> -#include <util/generic/vector.h> -#include <util/random/fast.h> -#include <util/generic/xrange.h> - -#include <cmath> -namespace { - template <typename T, size_t N> - struct TExamplesHolder { - TVector<T> Examples; - - TExamplesHolder() - : Examples(N) - { - TFastRng<ui64> prng{N * 42}; - for (auto& x : Examples) { - x = prng.GenRandReal4() + prng.Uniform(1932); // 1934 is just a random number - } - } - }; -} - -#define DEFINE_BENCHMARK(type, count) \ - Y_CPU_BENCHMARK(libm_log2f_##type##_##count, iface) { \ - const auto& examples = Default<TExamplesHolder<type, count>>().Examples; \ - for (const auto i : xrange(iface.Iterations())) { \ - Y_UNUSED(i); \ - for (const auto e : examples) { \ - Y_DO_NOT_OPTIMIZE_AWAY(log2f(e)); \ - } \ - } \ - } \ - \ - Y_CPU_BENCHMARK(libm_logf_##type##_##count, iface) { \ - const auto& examples = Default<TExamplesHolder<type, count>>().Examples; \ - for (const auto i : xrange(iface.Iterations())) { \ - Y_UNUSED(i); \ - for (const auto e : examples) { \ - Y_DO_NOT_OPTIMIZE_AWAY(logf(e)); \ - } \ - } \ - } \ - Y_CPU_BENCHMARK(STL_Log2_##type##_##count, iface) { \ - const auto& examples = Default<TExamplesHolder<type, count>>().Examples; \ - for (const auto i : xrange(iface.Iterations())) { \ - Y_UNUSED(i); \ - for (const auto e : examples) { \ - Y_DO_NOT_OPTIMIZE_AWAY(std::log2(e)); \ - } \ - } \ - } \ - \ - Y_CPU_BENCHMARK(STL_Log_##type##_##count, iface) { \ - const auto& examples = Default<TExamplesHolder<type, count>>().Examples; \ - for (const auto i : xrange(iface.Iterations())) { \ - Y_UNUSED(i); \ - for (const auto e : examples) { \ - Y_DO_NOT_OPTIMIZE_AWAY(std::log(e)); \ - } \ - } \ - } \ - \ - Y_CPU_BENCHMARK(Fast_Log2_##type##_##count, iface) { \ - const auto& examples = Default<TExamplesHolder<type, count>>().Examples; \ - for (const auto i : xrange(iface.Iterations())) { \ - Y_UNUSED(i); \ - for (const auto e : examples) { \ - Y_DO_NOT_OPTIMIZE_AWAY(FastLog2f(e)); \ - } \ - } \ - } \ - \ - Y_CPU_BENCHMARK(FastLogf##type##_##count, iface) { \ - const auto& examples = Default<TExamplesHolder<type, count>>().Examples; \ - for (const auto i : xrange(iface.Iterations())) { \ - Y_UNUSED(i); \ - for (const auto e : examples) { \ - Y_DO_NOT_OPTIMIZE_AWAY(FastLogf(e)); \ - } \ - } \ - } \ - \ - Y_CPU_BENCHMARK(Faster_Log2_##type##_##count, iface) { \ - const auto& examples = Default<TExamplesHolder<type, count>>().Examples; \ - for (const auto i : xrange(iface.Iterations())) { \ - Y_UNUSED(i); \ - for (const auto e : examples) { \ - Y_DO_NOT_OPTIMIZE_AWAY(FasterLog2f(e)); \ - } \ - } \ - } \ - \ - Y_CPU_BENCHMARK(Faster_Log_##type##_##count, iface) { \ - const auto& examples = Default<TExamplesHolder<type, count>>().Examples; \ - for (const auto i : xrange(iface.Iterations())) { \ - Y_UNUSED(i); \ - for (const auto e : examples) { \ - Y_DO_NOT_OPTIMIZE_AWAY(FasterLogf(e)); \ - } \ - } \ - } \ - \ - Y_CPU_BENCHMARK(Fastest_Log2f_##type##_##count, iface) { \ - const auto& examples = Default<TExamplesHolder<type, count>>().Examples; \ - for (const auto i : xrange(iface.Iterations())) { \ - Y_UNUSED(i); \ - for (const auto e : examples) { \ - Y_DO_NOT_OPTIMIZE_AWAY(FastestLog2f(e)); \ - } \ - } \ - } \ - \ - Y_CPU_BENCHMARK(Fastest_Log_##type##_##count, iface) { \ - const auto& examples = Default<TExamplesHolder<type, count>>().Examples; \ - for (const auto i : xrange(iface.Iterations())) { \ - Y_UNUSED(i); \ - for (const auto e : examples) { \ - Y_DO_NOT_OPTIMIZE_AWAY(FastestLogf(e)); \ - } \ - } \ - } - -DEFINE_BENCHMARK(float, 1) -DEFINE_BENCHMARK(float, 2) -DEFINE_BENCHMARK(float, 4) -DEFINE_BENCHMARK(float, 8) -DEFINE_BENCHMARK(float, 16) -DEFINE_BENCHMARK(float, 32) -DEFINE_BENCHMARK(float, 64) -DEFINE_BENCHMARK(float, 128) -DEFINE_BENCHMARK(float, 256) -DEFINE_BENCHMARK(float, 1024) -DEFINE_BENCHMARK(float, 2048) -DEFINE_BENCHMARK(float, 4096) - -#undef DEFINE_BENCHMARK diff --git a/util/generic/benchmark/log2/metrics/main.py b/util/generic/benchmark/log2/metrics/main.py deleted file mode 100644 index 26f6b57812b..00000000000 --- a/util/generic/benchmark/log2/metrics/main.py +++ /dev/null @@ -1,5 +0,0 @@ -import yatest.common as yc - - -def test_export_metrics(metrics): - metrics.set_benchmark(yc.execute_benchmark('util/generic/benchmark/log2/log2', threads=8)) diff --git a/util/generic/benchmark/rotate_bits/main.cpp b/util/generic/benchmark/rotate_bits/main.cpp deleted file mode 100644 index 057edbe864f..00000000000 --- a/util/generic/benchmark/rotate_bits/main.cpp +++ /dev/null @@ -1,66 +0,0 @@ -#include <library/cpp/testing/benchmark/bench.h> - -#include <util/generic/vector.h> -#include <util/generic/xrange.h> -#include <util/generic/singleton.h> - -#include <util/random/fast.h> - -namespace { - template <typename T> - struct TExample { - T Value; - ui8 Shift; - }; - - template <typename T, size_t N> - struct TExamplesHolder { - TExamplesHolder() - : Examples(N) - { - TFastRng<ui64> prng{42u * sizeof(T) * N}; - for (auto& e : Examples) { - e.Value = prng(); - e.Shift = prng() % (8 * sizeof(T)); - } - } - - TVector<TExample<T>> Examples; - }; -} - -#define DEFINE_BENCHMARKS_FOR_UNSIGNED_TYPES(type, count) \ - Y_CPU_BENCHMARK(LeftRotate_##type##_##count, iface) { \ - const auto& examples = Default<TExamplesHolder<type, count>>().Examples; \ - for (const auto i : xrange(iface.Iterations())) { \ - Y_UNUSED(i); \ - for (const auto e : examples) { \ - Y_DO_NOT_OPTIMIZE_AWAY(RotateBitsLeft(e.Value, e.Shift)); \ - } \ - } \ - } \ - \ - Y_CPU_BENCHMARK(RightRotate_##type##_##count, iface) { \ - const auto& examples = Default<TExamplesHolder<type, count>>().Examples; \ - for (const auto i : xrange(iface.Iterations())) { \ - Y_UNUSED(i); \ - for (const auto e : examples) { \ - Y_DO_NOT_OPTIMIZE_AWAY(RotateBitsRight(e.Value, e.Shift)); \ - } \ - } \ - } - -DEFINE_BENCHMARKS_FOR_UNSIGNED_TYPES(ui8, 1) -DEFINE_BENCHMARKS_FOR_UNSIGNED_TYPES(ui8, 10) -DEFINE_BENCHMARKS_FOR_UNSIGNED_TYPES(ui8, 100) -DEFINE_BENCHMARKS_FOR_UNSIGNED_TYPES(ui16, 1) -DEFINE_BENCHMARKS_FOR_UNSIGNED_TYPES(ui16, 10) -DEFINE_BENCHMARKS_FOR_UNSIGNED_TYPES(ui16, 100) -DEFINE_BENCHMARKS_FOR_UNSIGNED_TYPES(ui32, 1) -DEFINE_BENCHMARKS_FOR_UNSIGNED_TYPES(ui32, 10) -DEFINE_BENCHMARKS_FOR_UNSIGNED_TYPES(ui32, 100) -DEFINE_BENCHMARKS_FOR_UNSIGNED_TYPES(ui64, 1) -DEFINE_BENCHMARKS_FOR_UNSIGNED_TYPES(ui64, 10) -DEFINE_BENCHMARKS_FOR_UNSIGNED_TYPES(ui64, 100) - -#undef DEFINE_BENCHMARKS_FOR_UNSIGNED_TYPES diff --git a/util/generic/benchmark/rotate_bits/metrics/main.py b/util/generic/benchmark/rotate_bits/metrics/main.py deleted file mode 100644 index b30555775f9..00000000000 --- a/util/generic/benchmark/rotate_bits/metrics/main.py +++ /dev/null @@ -1,5 +0,0 @@ -import yatest.common as yc - - -def test_export_metrics(metrics): - metrics.set_benchmark(yc.execute_benchmark('util/generic/benchmark/rotate_bits/rotate_bits', threads=8)) diff --git a/util/generic/benchmark/singleton/f.cpp b/util/generic/benchmark/singleton/f.cpp deleted file mode 100644 index bf6da53d9c0..00000000000 --- a/util/generic/benchmark/singleton/f.cpp +++ /dev/null @@ -1,18 +0,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 deleted file mode 100644 index 2b06bd371d7..00000000000 --- a/util/generic/benchmark/singleton/main.cpp +++ /dev/null @@ -1,54 +0,0 @@ -#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()); - } -} diff --git a/util/generic/benchmark/smart_pointers/main.cpp b/util/generic/benchmark/smart_pointers/main.cpp deleted file mode 100644 index 92c2f923bb7..00000000000 --- a/util/generic/benchmark/smart_pointers/main.cpp +++ /dev/null @@ -1,14 +0,0 @@ -#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>()); - } -} diff --git a/util/generic/benchmark/sort/main.cpp b/util/generic/benchmark/sort/main.cpp deleted file mode 100644 index d58f491f4d5..00000000000 --- a/util/generic/benchmark/sort/main.cpp +++ /dev/null @@ -1,77 +0,0 @@ -#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) { - TVector<int> x = {1}; - - 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) { - TVector<int> x = {4, 3, 2, 1}; - - 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) { - TVector<int> x = {1}; - - 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) { - TVector<int> x = {4, 3, 2, 1}; - - 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); - } -} diff --git a/util/generic/benchmark/string/benchmarks.h b/util/generic/benchmark/string/benchmarks.h deleted file mode 100644 index e347d7ff474..00000000000 --- a/util/generic/benchmark/string/benchmarks.h +++ /dev/null @@ -1,188 +0,0 @@ -#pragma once - -// Define BENCHMARK_PREFIX and BENCHMARKED_CLASS before including this file. - -#include <util/generic/xrange.h> - -#define Y_CPU_PREFIXED_BENCHMARK_HELPER(prefix, name, iface) Y_CPU_BENCHMARK(prefix##name, iface) -#define Y_CPU_PREFIXED_BENCHMARK(prefix, name, iface) Y_CPU_PREFIXED_BENCHMARK_HELPER(prefix, name, iface) -#define CONCATENATE3_HELPER(a, b, c) a##b##c -#define CONCATENATE3(a, b, c) CONCATENATE3_HELPER(a, b, c) - -namespace { - namespace CONCATENATE3(N, BENCHMARK_PREFIX, Benchmark) { - using TBenchmarkedClass = BENCHMARKED_CLASS; - - const auto defaultString = TBenchmarkedClass(); - const auto emptyString = TBenchmarkedClass(""); - 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())) { - Y_UNUSED(i); - auto result = TBenchmarkedClass(); - Y_DO_NOT_OPTIMIZE_AWAY(result); - } - } - - Y_CPU_PREFIXED_BENCHMARK(BENCHMARK_PREFIX, CreateFromEmptyLiteral, iface) { - for (const auto i : xrange(iface.Iterations())) { - Y_UNUSED(i); - auto result = TBenchmarkedClass(""); - Y_DO_NOT_OPTIMIZE_AWAY(result); - } - } - - Y_CPU_PREFIXED_BENCHMARK(BENCHMARK_PREFIX, CreateFromLengthOneLiteral, iface) { - for (const auto i : xrange(iface.Iterations())) { - Y_UNUSED(i); - auto result = TBenchmarkedClass("1"); - Y_DO_NOT_OPTIMIZE_AWAY(result); - } - } - - Y_CPU_PREFIXED_BENCHMARK(BENCHMARK_PREFIX, CreateLength1K, iface) { - for (const auto i : xrange(iface.Iterations())) { - Y_UNUSED(i); - auto result = TBenchmarkedClass(1000, '1'); - Y_DO_NOT_OPTIMIZE_AWAY(result); - } - } - - Y_CPU_PREFIXED_BENCHMARK(BENCHMARK_PREFIX, CopyDefaultString, iface) { - const auto& sourceString = defaultString; - for (const auto i : xrange(iface.Iterations())) { - Y_UNUSED(i); - auto result = TBenchmarkedClass(sourceString); - Y_DO_NOT_OPTIMIZE_AWAY(result); - } - } - - Y_CPU_PREFIXED_BENCHMARK(BENCHMARK_PREFIX, CopyEmptyString, iface) { - const auto& sourceString = emptyString; - for (const auto i : xrange(iface.Iterations())) { - Y_UNUSED(i); - auto result = TBenchmarkedClass(sourceString); - Y_DO_NOT_OPTIMIZE_AWAY(result); - } - } - - Y_CPU_PREFIXED_BENCHMARK(BENCHMARK_PREFIX, CopyLengthOneString, iface) { - const auto& sourceString = lengthOneString; - for (const auto i : xrange(iface.Iterations())) { - Y_UNUSED(i); - auto result = TBenchmarkedClass(sourceString); - Y_DO_NOT_OPTIMIZE_AWAY(result); - } - } - - Y_CPU_PREFIXED_BENCHMARK(BENCHMARK_PREFIX, CopyLength1KString, iface) { - const auto& sourceString = length1KString; - for (const auto i : xrange(iface.Iterations())) { - Y_UNUSED(i); - auto result = TBenchmarkedClass(sourceString); - Y_DO_NOT_OPTIMIZE_AWAY(result); - } - } - - Y_CPU_PREFIXED_BENCHMARK(BENCHMARK_PREFIX, CopyAndUpdateLengthOneString, iface) { - const auto& sourceString = lengthOneString; - for (const auto i : xrange(iface.Iterations())) { - Y_UNUSED(i); - auto targetString = TBenchmarkedClass(sourceString); - auto result = targetString[0] = '0'; - Y_DO_NOT_OPTIMIZE_AWAY(targetString); - Y_DO_NOT_OPTIMIZE_AWAY(result); - } - } - - Y_CPU_PREFIXED_BENCHMARK(BENCHMARK_PREFIX, CopyAndAppendDefaultString, iface) { - const auto& sourceString = defaultString; - const TBenchmarkedClass::size_type insertPosition = sourceString.size(); - for (const auto i : xrange(iface.Iterations())) { - Y_UNUSED(i); - auto targetString = TBenchmarkedClass(sourceString); - auto result = targetString.insert(insertPosition, 1, '0'); - Y_DO_NOT_OPTIMIZE_AWAY(targetString); - Y_DO_NOT_OPTIMIZE_AWAY(result); - } - } - - Y_CPU_PREFIXED_BENCHMARK(BENCHMARK_PREFIX, CopyAndAppendEmptyString, iface) { - const auto& sourceString = emptyString; - const TBenchmarkedClass::size_type insertPosition = sourceString.size(); - for (const auto i : xrange(iface.Iterations())) { - Y_UNUSED(i); - auto targetString = TBenchmarkedClass(sourceString); - auto result = targetString.insert(insertPosition, 1, '0'); - Y_DO_NOT_OPTIMIZE_AWAY(targetString); - Y_DO_NOT_OPTIMIZE_AWAY(result); - } - } - - Y_CPU_PREFIXED_BENCHMARK(BENCHMARK_PREFIX, CopyAndAppendLengthOneString, iface) { - const auto& sourceString = lengthOneString; - const TBenchmarkedClass::size_type insertPosition = sourceString.size(); - for (const auto i : xrange(iface.Iterations())) { - Y_UNUSED(i); - auto targetString = TBenchmarkedClass(sourceString); - auto result = targetString.insert(insertPosition, 1, '0'); - Y_DO_NOT_OPTIMIZE_AWAY(targetString); - Y_DO_NOT_OPTIMIZE_AWAY(result); - } - } - - Y_CPU_PREFIXED_BENCHMARK(BENCHMARK_PREFIX, CopyAndPrependLengthOneString, iface) { - const auto& sourceString = lengthOneString; - const TBenchmarkedClass::size_type insertPosition = 0; - for (const auto i : xrange(iface.Iterations())) { - Y_UNUSED(i); - auto targetString = TBenchmarkedClass(sourceString); - auto result = targetString.insert(insertPosition, 1, '0'); - Y_DO_NOT_OPTIMIZE_AWAY(targetString); - Y_DO_NOT_OPTIMIZE_AWAY(result); - } - } - - Y_CPU_PREFIXED_BENCHMARK(BENCHMARK_PREFIX, CopyAndUpdateLength1KString, iface) { - const auto& sourceString = length1KString; - for (const auto i : xrange(iface.Iterations())) { - Y_UNUSED(i); - auto targetString = TBenchmarkedClass(sourceString); - auto result = targetString[0] = '0'; - Y_DO_NOT_OPTIMIZE_AWAY(targetString); - Y_DO_NOT_OPTIMIZE_AWAY(result); - } - } - - Y_CPU_PREFIXED_BENCHMARK(BENCHMARK_PREFIX, CopyAndAppendLength1KString, iface) { - const auto& sourceString = length1KString; - const TBenchmarkedClass::size_type insertPosition = sourceString.size(); - for (const auto i : xrange(iface.Iterations())) { - Y_UNUSED(i); - auto targetString = TBenchmarkedClass(sourceString); - auto result = targetString.insert(insertPosition, 1, '0'); - Y_DO_NOT_OPTIMIZE_AWAY(targetString); - Y_DO_NOT_OPTIMIZE_AWAY(result); - } - } - - Y_CPU_PREFIXED_BENCHMARK(BENCHMARK_PREFIX, CopyAndPrependLength1KString, iface) { - const auto& sourceString = length1KString; - const TBenchmarkedClass::size_type insertPosition = 0; - for (const auto i : xrange(iface.Iterations())) { - Y_UNUSED(i); - auto targetString = TBenchmarkedClass(sourceString); - auto result = targetString.insert(insertPosition, 1, '0'); - Y_DO_NOT_OPTIMIZE_AWAY(targetString); - Y_DO_NOT_OPTIMIZE_AWAY(result); - } - } - } -} - -#undef CONCATENATE3 -#undef CONCATENATE3_HELPER -#undef Y_CPU_PREFIXED_BENCHMARK -#undef Y_CPU_PREFIXED_BENCHMARK_HELPER diff --git a/util/generic/benchmark/string/std_string.cpp b/util/generic/benchmark/string/std_string.cpp deleted file mode 100644 index cb10b4dc0c6..00000000000 --- a/util/generic/benchmark/string/std_string.cpp +++ /dev/null @@ -1,8 +0,0 @@ -#include <library/cpp/testing/benchmark/bench.h> - -#include <string> - -#define BENCHMARK_PREFIX StdString -#define BENCHMARKED_CLASS std::string - -#include "benchmarks.h" diff --git a/util/generic/benchmark/string/string.cpp b/util/generic/benchmark/string/string.cpp deleted file mode 100644 index c634c204d84..00000000000 --- a/util/generic/benchmark/string/string.cpp +++ /dev/null @@ -1,8 +0,0 @@ -#include <library/cpp/testing/benchmark/bench.h> - -#include <util/generic/string.h> - -#define BENCHMARK_PREFIX TString -#define BENCHMARKED_CLASS ::TString - -#include "benchmarks.h" diff --git a/util/generic/benchmark/vector_count_ctor/f.cpp b/util/generic/benchmark/vector_count_ctor/f.cpp deleted file mode 100644 index b89e351ba72..00000000000 --- a/util/generic/benchmark/vector_count_ctor/f.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#include "f.h" - -#include <library/cpp/testing/benchmark/bench.h> - -#include <util/generic/vector.h> -#include <util/generic/ptr.h> - -void CreateYvector(const size_t size, const size_t count) { - for (size_t i = 0; i < count; ++i) { - NBench::Clobber(); - TVector<ui8> v(size); - NBench::Escape(v.data()); - NBench::Clobber(); - } -} - -void CreateCarray(const size_t size, const size_t count) { - for (size_t i = 0; i < count; ++i) { - NBench::Clobber(); - TArrayHolder<ui8> v(new ui8[size]); - memset(v.Get(), 0, size * sizeof(ui8)); - NBench::Escape(v.Get()); - NBench::Clobber(); - } -} diff --git a/util/generic/benchmark/vector_count_ctor/f.h b/util/generic/benchmark/vector_count_ctor/f.h deleted file mode 100644 index a568341a456..00000000000 --- a/util/generic/benchmark/vector_count_ctor/f.h +++ /dev/null @@ -1,9 +0,0 @@ -#pragma once - -#include <cstddef> - -// functions are declared in a separate translation unit so that compiler won't be able to see the -// value of `size` during compilation. - -void CreateYvector(const size_t size, const size_t count); -void CreateCarray(const size_t size, const size_t count); diff --git a/util/generic/benchmark/vector_count_ctor/main.cpp b/util/generic/benchmark/vector_count_ctor/main.cpp deleted file mode 100644 index 6fb1fda9c94..00000000000 --- a/util/generic/benchmark/vector_count_ctor/main.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include "f.h" - -#include <library/cpp/testing/benchmark/bench.h> - -#define DEFINE_BENCHMARK(N) \ - Y_CPU_BENCHMARK(Yvector_##N, iface) { \ - CreateYvector(N, iface.Iterations()); \ - } \ - Y_CPU_BENCHMARK(Carray_##N, iface) { \ - CreateCarray(N, iface.Iterations()); \ - } - -DEFINE_BENCHMARK(1) -DEFINE_BENCHMARK(2) -DEFINE_BENCHMARK(8) -DEFINE_BENCHMARK(10) -DEFINE_BENCHMARK(16) -DEFINE_BENCHMARK(20) -DEFINE_BENCHMARK(1000) -DEFINE_BENCHMARK(1024) -DEFINE_BENCHMARK(8192) -DEFINE_BENCHMARK(10000) -DEFINE_BENCHMARK(65536) -DEFINE_BENCHMARK(100000) -DEFINE_BENCHMARK(4194304) -DEFINE_BENCHMARK(1000000) -DEFINE_BENCHMARK(33554432) -DEFINE_BENCHMARK(10000000) -DEFINE_BENCHMARK(268435456) -DEFINE_BENCHMARK(100000000) diff --git a/util/generic/benchmark/vector_count_ctor/metrics/main.py b/util/generic/benchmark/vector_count_ctor/metrics/main.py deleted file mode 100644 index 835b44fe5f7..00000000000 --- a/util/generic/benchmark/vector_count_ctor/metrics/main.py +++ /dev/null @@ -1,5 +0,0 @@ -import yatest.common as yc - - -def test_export_metrics(metrics): - metrics.set_benchmark(yc.execute_benchmark('util/generic/benchmark/vector_count_ctor/vector_count_ctor', threads=8)) diff --git a/util/generic/fuzz/vector/main.cpp b/util/generic/fuzz/vector/main.cpp deleted file mode 100644 index 0a0293f7954..00000000000 --- a/util/generic/fuzz/vector/main.cpp +++ /dev/null @@ -1,47 +0,0 @@ -#include <util/generic/vector.h> -#include <util/stream/mem.h> - -template <class T> -static inline T Read(IInputStream& in) { - T t; - - in.LoadOrFail(&t, sizeof(t)); - - return t; -} - -extern "C" int LLVMFuzzerTestOneInput(const ui8* data, size_t size) { - TMemoryInput mi(data, size); - - try { - TVector<ui16> v; - - while (mi.Avail()) { - char cmd = Read<char>(mi); - - switch (cmd % 2) { - case 0: { - const size_t cnt = 1 + Read<ui8>(mi) % 16; - - for (size_t i = 0; i < cnt; ++i) { - v.push_back(i); - } - - break; - } - - case 1: { - if (v) { - v.pop_back(); - } - - break; - } - } - } - } catch (...) { - // ¯\_(ツ)_/¯ - } - - return 0; // Non-zero return values are reserved for future use. -} diff --git a/util/generic/va_args_gen.py b/util/generic/va_args_gen.py deleted file mode 100755 index 232b53fca6d..00000000000 --- a/util/generic/va_args_gen.py +++ /dev/null @@ -1,211 +0,0 @@ -#!/usr/bin/env python -""" -Generates some handy macros for preprocessor metaprogramming. - -""" - -from __future__ import print_function - -import sys -import textwrap - -if sys.version_info >= (3, 0, 0): - xrange = range - - -def generate(limit): - print('#pragma once') - print(textwrap.dedent(''' - /// @file va_args.h - /// - /// Some handy macros for preprocessor metaprogramming. - '''.rstrip())) - print('') - command = ' '.join(sys.argv) - print('// NOTE: this file has been generated with "{}", do not edit -- use the generator instead'.format(command)) - print('') - print('// DO_NOT_STYLE') - print('') - print('#include <util/system/defaults.h>') - print('') - - pass_va_args() - count(limit) - get_elem(limit) - map_args(limit) - map_args_n(limit) - map_args_with_last(limit) - map_args_with_last_n(limit) - all_but_last(limit) - last(limit) - impl_dispatcher() - - -def pass_va_args(): - print(textwrap.dedent(''' - /** - * Triggers another level of macro expansion, use whenever passing __VA_ARGS__ to another macro. - * - * Used merely for working around an MSVC++ bug. - * See http://stackoverflow.com/questions/5134523/msvc-doesnt-expand-va-args-correctly - */ - '''.rstrip())) - print('#define Y_PASS_VA_ARGS(x) x') - - -def count(limit): - print(textwrap.dedent(''' - /** - * Count number of arguments in `__VA_ARGS__`. - * Doesn't work with empty arguments list. - */ - '''.rstrip())) - numbers = ', '.join(map(str, xrange(limit, -1, -1))) - u_numbers = ', '.join(map('_{}'.format, xrange(limit, 0, -1))) - print('#define Y_COUNT_ARGS(...) Y_PASS_VA_ARGS(' - '__Y_COUNT_ARGS(__VA_ARGS__, {}))'.format(numbers)) - print('#define __Y_COUNT_ARGS({}, N, ...) N'.format(u_numbers)) - - -def get_elem(limit): - print(textwrap.dedent(''' - /** - * Get the i-th element from `__VA_ARGS__`. - */ - '''.rstrip())) - print('#define Y_GET_ARG(N, ...) Y_PASS_VA_ARGS(Y_PASS_VA_ARGS(Y_CAT(__Y_GET_ARG_, ' - 'N))(__VA_ARGS__))') - for i in xrange(0, limit + 1): - args = ', '.join(map('_{}'.format, xrange(i + 1))) - print('#define __Y_GET_ARG_{}({}, ...) _{}'.format(i, args, i)) - - -def map_args(limit): - print(textwrap.dedent(''' - /** - * Expands a macro for each of the variable arguments. - * Doesn't work with empty arguments list. - */ - '''.rstrip())) - print('#define Y_MAP_ARGS(ACTION, ...) Y_PASS_VA_ARGS(Y_PASS_VA_ARGS(Y_CAT(' - '__Y_MAP_ARGS_, Y_COUNT_ARGS(__VA_ARGS__)))(ACTION, __VA_ARGS__))') - print('#define __Y_MAP_ARGS_0(...)') - print('#define __Y_MAP_ARGS_1(ACTION, x, ...) ACTION(x)') - for i in xrange(2, limit + 1): - print('#define __Y_MAP_ARGS_{}(ACTION, x, ...) ACTION(x) Y_PASS_VA_ARGS(__Y_MAP_ARGS_{}(' - 'ACTION, __VA_ARGS__))'.format(i, i - 1)) - - -def map_args_n(limit): - print(textwrap.dedent(''' - /** - * Expands a macro for each of the variable arguments with it's sequence number and value. - * Corresponding sequence numbers will expand in descending order. - * Doesn't work with empty arguments list. - */ - '''.rstrip())) - print('#define Y_MAP_ARGS_N(ACTION, ...) Y_PASS_VA_ARGS(Y_PASS_VA_ARGS(Y_CAT(' - '__Y_MAP_ARGS_N_, Y_COUNT_ARGS(__VA_ARGS__)))(ACTION, __VA_ARGS__))') - print('#define __Y_MAP_ARGS_N_0(...)') - print('#define __Y_MAP_ARGS_N_1(ACTION, x, ...) ACTION(1, x)') - for i in xrange(2, limit + 1): - print('#define __Y_MAP_ARGS_N_{}(ACTION, x, ...) ACTION({}, x) Y_PASS_VA_ARGS(__Y_MAP_ARGS_N_{}(' - 'ACTION, __VA_ARGS__))'.format(i, i, i - 1)) - - -def map_args_with_last(limit): - print(textwrap.dedent(''' - /** - * Expands a macro for each of the variable arguments. - * Doesn't work with empty arguments list. - */ - '''.rstrip())) - print('#define Y_MAP_ARGS_WITH_LAST(ACTION, LAST_ACTION, ...) Y_PASS_VA_ARGS(Y_PASS_VA_ARGS(' - 'Y_CAT(__Y_MAP_ARGS_WITH_LAST_, Y_COUNT_ARGS(__VA_ARGS__)))(ACTION, LAST_ACTION, ' - '__VA_ARGS__))') - print('#define __Y_MAP_ARGS_WITH_LAST_0(...)') - print('#define __Y_MAP_ARGS_WITH_LAST_1(ACTION, LAST_ACTION, x, ...) LAST_ACTION(x)') - for i in xrange(2, limit + 1): - print('#define __Y_MAP_ARGS_WITH_LAST_{}(ACTION, LAST_ACTION, x, ...) ACTION(x) Y_PASS_VA_ARGS(' - '__Y_MAP_ARGS_WITH_LAST_{}(ACTION, LAST_ACTION, __VA_ARGS__))'.format(i, i - 1)) - - -def map_args_with_last_n(limit): - print(textwrap.dedent(''' - /** - * Expands a macro for each of the variable arguments with it's sequence number and value. - * Corresponding sequence numbers will expand in descending order. - * Doesn't work with empty arguments list. - */ - '''.rstrip())) - print('#define Y_MAP_ARGS_WITH_LAST_N(ACTION, LAST_ACTION, ...) Y_PASS_VA_ARGS(Y_PASS_VA_ARGS(' - 'Y_CAT(__Y_MAP_ARGS_WITH_LAST_N_, Y_COUNT_ARGS(__VA_ARGS__)))(ACTION, LAST_ACTION, ' - '__VA_ARGS__))') - print('#define __Y_MAP_ARGS_WITH_LAST_N_0(...)') - print('#define __Y_MAP_ARGS_WITH_LAST_N_1(ACTION, LAST_ACTION, x, ...) LAST_ACTION(1, x)') - for i in xrange(2, limit + 1): - print('#define __Y_MAP_ARGS_WITH_LAST_N_{}(ACTION, LAST_ACTION, x, ...) ACTION({}, x) Y_PASS_VA_ARGS(' - '__Y_MAP_ARGS_WITH_LAST_N_{}(ACTION, LAST_ACTION, __VA_ARGS__))'.format(i, i, i - 1)) - - -def all_but_last(limit): - print(textwrap.dedent(''' - /** - * Get all elements but the last one from `__VA_ARGS__`. - * Doesn't work with empty arguments list. - */ - '''.rstrip())) - print('#define Y_ALL_BUT_LAST(...) Y_PASS_VA_ARGS(Y_PASS_VA_ARGS(Y_CAT(__Y_ALL_BUT_LAST_, ' - 'Y_COUNT_ARGS(__VA_ARGS__)))(__VA_ARGS__))') - print('#define __Y_ALL_BUT_LAST_0(...)') - print('#define __Y_ALL_BUT_LAST_1(...)') - for i in xrange(2, limit + 1): - args = ', '.join(map('_{}'.format, xrange(i - 1))) - print('#define __Y_ALL_BUT_LAST_{}({}, ...) {}'.format(i, args, args)) - - -def last(limit): - print(textwrap.dedent(''' - /** - * Get the last element from `__VA_ARGS__`. - * Doesn't work with empty arguments list. - */ - '''.rstrip())) - print('#define Y_LAST(...) Y_PASS_VA_ARGS(' - 'Y_GET_ARG(Y_COUNT_ARGS(__VA_ARGS__), , __VA_ARGS__, {}))'.format(',' * limit)) - - -def impl_dispatcher(): - print(textwrap.dedent(''' - /** - * Macros for implementing overload by number of arguments. - * - * Example usage: - * - * @code{cpp} - * #define I1(arg1) Cout << Y_STRINGIZE(arg1) << Endl; - * #define I2(arg1, arg2) Cout << Y_STRINGIZE(arg1) << ';' << Y_STRINGIZE(arg2) << Endl; - * - * #define Y_PRINT(...) Y_PASS_VA_ARGS(Y_MACRO_IMPL_DISPATCHER_2(__VA_ARGS__, I2, I1)(__VA_ARGS__)) - * @endcode - */ - '''.rstrip())) - print('/// @{') - for i in xrange(2, 11): - args = ', '.join(map('_{}'.format, xrange(i))) - print('#define Y_MACRO_IMPL_DISPATCHER_{}({}, IMPL, ...) IMPL'.format(i, args)) - print('/// }@') - - -def main(): - if len(sys.argv) > 2: - sys.stderr.write('Usage: {} [limit=50]\n'.format(sys.argv[0])) - sys.exit(1) - limit = 50 - if len(sys.argv) == 2: - limit = int(sys.argv[1]) - generate(limit) - - -if __name__ == '__main__': - main() |