aboutsummaryrefslogtreecommitdiffhomepage
path: root/tdutils/test
diff options
context:
space:
mode:
authorlevlam <levlam@telegram.org>2023-07-26 14:40:36 +0300
committerlevlam <levlam@telegram.org>2023-07-26 14:40:36 +0300
commit69c2315c10474470caa2d326372654d6d34a2daa (patch)
tree00514002164503643816d66734c5fd6d2633e4ed /tdutils/test
parent4c2859b85c8950810890a7b380dcc2ab30772238 (diff)
Add zero_encode benchamrk.
Diffstat (limited to 'tdutils/test')
-rw-r--r--tdutils/test/misc.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/tdutils/test/misc.cpp b/tdutils/test/misc.cpp
index 140223373..aaea9fa7c 100644
--- a/tdutils/test/misc.cpp
+++ b/tdutils/test/misc.cpp
@@ -7,6 +7,7 @@
#include "td/utils/algorithm.h"
#include "td/utils/as.h"
#include "td/utils/base64.h"
+#include "td/utils/benchmark.h"
#include "td/utils/BigNum.h"
#include "td/utils/bits.h"
#include "td/utils/CancellationToken.h"
@@ -304,6 +305,26 @@ TEST(Misc, zero_encode) {
test_zero_encode(str + td::string(1000, '\0') + str + td::string(1000, '\xff') + str);
}
+class ZeroEncodeBenchmark final : public td::Benchmark {
+ public:
+ td::string get_description() const final {
+ return "ZeroEncodeBenchmark";
+ }
+
+ void run(int n) final {
+ for (int i = 0; i < n; i++) {
+ zero_encode(
+ td::Slice("\x02\x00\x00\x02\x01\x00\x00\x00\x19\x01\x00\x00\x7c\xc8\x64\xc1\x04\xec\x82\xb8\x20\x9e\xa0\x8d"
+ "\x1e\xbe\xb2\x79\xc4\x5a\x4c\x1e\x49\x1e\x00\x00\xa9\xa7\x31\x1b\x80\x9f\x11\x46\xfc\x97\xde\x6a"
+ "\x18\x6e\xc0\x73\x01\x00\x00\x00\x02\x00\x00\x00\x6d\x00\x00\x00\x30\x04"));
+ }
+ }
+};
+
+TEST(Misc, bench_zero_encode) {
+ td::bench(ZeroEncodeBenchmark());
+}
+
template <class T>
static void test_remove_if(td::vector<int> v, const T &func, const td::vector<int> &expected) {
td::remove_if(v, func);