aboutsummaryrefslogtreecommitdiffhomepage
path: root/benchmark/bench_handshake.cpp
diff options
context:
space:
mode:
authorlevlam <levlam@telegram.org>2021-11-06 23:45:02 +0300
committerlevlam <levlam@telegram.org>2021-11-06 23:45:02 +0300
commit8c3d9a7710dccc2ef47d2cb39b0e9e4f7d0ed987 (patch)
treec1254973b341f6b66438b1d8130871d7850baf0b /benchmark/bench_handshake.cpp
parenteb346f5573040803d4424049dd2ba8aaa039fa56 (diff)
Move benchmarks out of namespace td.
Diffstat (limited to 'benchmark/bench_handshake.cpp')
-rw-r--r--benchmark/bench_handshake.cpp32
1 files changed, 14 insertions, 18 deletions
diff --git a/benchmark/bench_handshake.cpp b/benchmark/bench_handshake.cpp
index 2b7efebd6..13cefad63 100644
--- a/benchmark/bench_handshake.cpp
+++ b/benchmark/bench_handshake.cpp
@@ -19,43 +19,41 @@
#include <semaphore.h>
#endif
-namespace td {
-
-static int32 g = 3;
-static string prime_base64 =
+static td::int32 g = 3;
+static td::string prime_base64 =
"xxyuucaxyQSObFIvcPE_c5gNQCOOPiHBSTTQN1Y9kw9IGYoKp8FAWCKUk9IlMPTb-jNvbgrJJROVQ67UTM58NyD9UfaUWHBaxozU_mtrE6vcl0ZRKW"
"kyhFTxj6-MWV9kJHf-lrsqlB1bzR1KyMxJiAcI-ps3jjxPOpBgvuZ8-aSkppWBEFGQfhYnU7VrD2tBDbp02KhLKhSzFE4O8ShHVP0X7ZUNWWW0ud1G"
"WC2xF40WnGvEZbDW_5yjko_vW5rk5Bj8Feg-vqD4f6n_Xu1wBQ3tKEn0e_lZ2VaFDOkphR8NgRX2NbEF7i5OFdBLJFS_b0-t8DSxBAMRnNjjuS_MW"
"w";
-class HandshakeBench final : public Benchmark {
- std::string get_description() const final {
+class HandshakeBench final : public td::Benchmark {
+ td::string get_description() const final {
return "Handshake";
}
- class FakeDhCallback final : public mtproto::DhCallback {
+ class FakeDhCallback final : public td::mtproto::DhCallback {
public:
- int is_good_prime(Slice prime_str) const final {
+ int is_good_prime(td::Slice prime_str) const final {
auto it = cache.find(prime_str.str());
if (it == cache.end()) {
return -1;
}
return it->second;
}
- void add_good_prime(Slice prime_str) const final {
+ void add_good_prime(td::Slice prime_str) const final {
cache[prime_str.str()] = 1;
}
- void add_bad_prime(Slice prime_str) const final {
+ void add_bad_prime(td::Slice prime_str) const final {
cache[prime_str.str()] = 0;
}
- mutable std::map<string, int> cache;
+ mutable std::map<td::string, int> cache;
} dh_callback;
void run(int n) final {
- mtproto::DhHandshake a;
- mtproto::DhHandshake b;
- auto prime = base64url_decode(prime_base64).move_as_ok();
- mtproto::DhHandshake::check_config(g, prime, &dh_callback).ensure();
+ td::mtproto::DhHandshake a;
+ td::mtproto::DhHandshake b;
+ auto prime = td::base64url_decode(prime_base64).move_as_ok();
+ td::mtproto::DhHandshake::check_config(g, prime, &dh_callback).ensure();
for (int i = 0; i < n; i += 2) {
a.set_config(g, prime);
b.set_config(g, prime);
@@ -69,9 +67,7 @@ class HandshakeBench final : public Benchmark {
}
}
};
-} // namespace td
int main() {
- SET_VERBOSITY_LEVEL(VERBOSITY_NAME(DEBUG));
- td::bench(td::HandshakeBench());
+ td::bench(HandshakeBench());
}