diff options
Diffstat (limited to 'protocols/Telegram/tdlib/td/benchmark/bench_http_reader.cpp')
-rw-r--r-- | protocols/Telegram/tdlib/td/benchmark/bench_http_reader.cpp | 40 |
1 files changed, 19 insertions, 21 deletions
diff --git a/protocols/Telegram/tdlib/td/benchmark/bench_http_reader.cpp b/protocols/Telegram/tdlib/td/benchmark/bench_http_reader.cpp index 2afe2d73ff..403af06bec 100644 --- a/protocols/Telegram/tdlib/td/benchmark/bench_http_reader.cpp +++ b/protocols/Telegram/tdlib/td/benchmark/bench_http_reader.cpp @@ -1,5 +1,5 @@ // -// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2018 +// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2022 // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -9,19 +9,20 @@ #include "td/utils/benchmark.h" #include "td/utils/buffer.h" +#include "td/utils/common.h" #include "td/utils/find_boundary.h" #include "td/utils/logging.h" static std::string http_query = "GET / HTTP/1.1\r\nConnection:keep-alive\r\nhost:127.0.0.1:8080\r\n\r\n"; static const size_t block_size = 2500; -class HttpReaderBench : public td::Benchmark { - std::string get_description() const override { +class HttpReaderBench final : public td::Benchmark { + std::string get_description() const final { return "HttpReaderBench"; } - void run(int n) override { - int cnt = static_cast<int>(block_size / http_query.size()); + void run(int n) final { + auto cnt = static_cast<int>(block_size / http_query.size()); td::HttpQuery q; int parsed = 0; int sent = 0; @@ -45,27 +46,26 @@ class HttpReaderBench : public td::Benchmark { td::ChainBufferReader reader_; td::HttpReader http_reader_; - void start_up() override { - writer_ = td::ChainBufferWriter::create_empty(); + void start_up() final { reader_ = writer_.extract_reader(); http_reader_.init(&reader_, 10000, 0); } }; -class BufferBench : public td::Benchmark { - std::string get_description() const override { +class BufferBench final : public td::Benchmark { + std::string get_description() const final { return "BufferBench"; } - void run(int n) override { - int cnt = static_cast<int>(block_size / http_query.size()); + void run(int n) final { + auto cnt = static_cast<int>(block_size / http_query.size()); for (int i = 0; i < n; i += cnt) { for (int j = 0; j < cnt; j++) { writer_.append(http_query); } reader_.sync_with_writer(); for (int j = 0; j < cnt; j++) { - reader_.cut_head(http_query.size()); + auto result = reader_.cut_head(http_query.size()); } } } @@ -73,19 +73,18 @@ class BufferBench : public td::Benchmark { td::ChainBufferReader reader_; td::HttpReader http_reader_; - void start_up() override { - writer_ = td::ChainBufferWriter::create_empty(); + void start_up() final { reader_ = writer_.extract_reader(); } }; -class FindBoundaryBench : public td::Benchmark { - std::string get_description() const override { +class FindBoundaryBench final : public td::Benchmark { + std::string get_description() const final { return "FindBoundaryBench"; } - void run(int n) override { - int cnt = static_cast<int>(block_size / http_query.size()); + void run(int n) final { + auto cnt = static_cast<int>(block_size / http_query.size()); for (int i = 0; i < n; i += cnt) { for (int j = 0; j < cnt; j++) { writer_.append(http_query); @@ -95,7 +94,7 @@ class FindBoundaryBench : public td::Benchmark { size_t len = 0; find_boundary(reader_.clone(), "\r\n\r\n", len); CHECK(size_t(len) + 4 == http_query.size()); - reader_.cut_head(len + 2); + auto result = reader_.cut_head(len + 2); reader_.advance(2); } } @@ -104,8 +103,7 @@ class FindBoundaryBench : public td::Benchmark { td::ChainBufferReader reader_; td::HttpReader http_reader_; - void start_up() override { - writer_ = td::ChainBufferWriter::create_empty(); + void start_up() final { reader_ = writer_.extract_reader(); } }; |