polished up event loop changes
Some checks failed
Docker Build & Publish / build (push) Failing after 55m49s
Some checks failed
Docker Build & Publish / build (push) Failing after 55m49s
This commit is contained in:
parent
058c395095
commit
409024e04a
18 changed files with 354 additions and 428 deletions
|
@ -1,21 +1,21 @@
|
|||
#include <gtest/gtest.h>
|
||||
#include <fstream>
|
||||
#include <chrono>
|
||||
#include "../lib/http/request.hpp"
|
||||
#include <chrono>
|
||||
#include <fstream>
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#ifdef SPEEDTEST_COMPARE_BOOST
|
||||
#include <boost/beast.hpp>
|
||||
#endif
|
||||
|
||||
|
||||
using std::chrono::high_resolution_clock;
|
||||
using std::chrono::duration_cast;
|
||||
using std::chrono::duration;
|
||||
using std::chrono::duration_cast;
|
||||
using std::chrono::high_resolution_clock;
|
||||
using std::chrono::milliseconds;
|
||||
|
||||
constexpr uint32_t num_requests = 10000000;
|
||||
|
||||
TEST(speed_tests, request_parse) {
|
||||
TEST(speed_tests, request_parse)
|
||||
{
|
||||
std::ifstream t("./test_files/test_request.http");
|
||||
std::stringstream buffer;
|
||||
buffer << t.rdbuf();
|
||||
|
@ -23,24 +23,25 @@ TEST(speed_tests, request_parse) {
|
|||
|
||||
auto start = high_resolution_clock::now();
|
||||
|
||||
for(int i = 0; i < num_requests; ++i) {
|
||||
volatile anthracite::http::request req (raw_req, "0.0.0.0");
|
||||
for (int i = 0; i < num_requests; ++i) {
|
||||
volatile anthracite::http::request req(raw_req, "0.0.0.0");
|
||||
}
|
||||
|
||||
auto end = high_resolution_clock::now();
|
||||
|
||||
auto ms_int = duration_cast<milliseconds>(end-start);
|
||||
auto ms_int = duration_cast<milliseconds>(end - start);
|
||||
|
||||
double m_rps = ((1000.0 / ms_int.count()) * num_requests) / 1000000;
|
||||
|
||||
std::cout << "Parsed " << (num_requests/1000000) << " Million requests in " << ms_int << " ms";
|
||||
std::cout << "Parsed " << (num_requests / 1000000) << " Million requests in " << ms_int << " ms";
|
||||
std::cout << " at " << m_rps << " Million RPS " << std::endl;
|
||||
|
||||
ASSERT_LT(ms_int.count(), 2000);
|
||||
}
|
||||
|
||||
#ifdef SPEEDTEST_COMPARE_BOOST
|
||||
TEST(speed_tests, boost) {
|
||||
TEST(speed_tests, boost)
|
||||
{
|
||||
std::ifstream t("./test_files/test_request.http");
|
||||
std::stringstream buffer;
|
||||
buffer << t.rdbuf();
|
||||
|
@ -48,7 +49,7 @@ TEST(speed_tests, boost) {
|
|||
|
||||
auto start = high_resolution_clock::now();
|
||||
|
||||
for(int i = 0; i < num_requests; ++i) {
|
||||
for (int i = 0; i < num_requests; ++i) {
|
||||
boost::system::error_code ec;
|
||||
boost::beast::http::request_parser<boost::beast::http::string_body> p;
|
||||
p.put(boost::asio::buffer(raw_req), ec);
|
||||
|
@ -56,11 +57,11 @@ TEST(speed_tests, boost) {
|
|||
}
|
||||
|
||||
auto end = high_resolution_clock::now();
|
||||
auto ms_int = duration_cast<milliseconds>(end-start);
|
||||
auto ms_int = duration_cast<milliseconds>(end - start);
|
||||
|
||||
double m_rps = ((1000.0 / ms_int.count()) * num_requests) / 1000000;
|
||||
|
||||
std::cout << "Parsed " << (num_requests/1000000) << " Million requests in " << ms_int << " ms";
|
||||
std::cout << "Parsed " << (num_requests / 1000000) << " Million requests in " << ms_int << " ms";
|
||||
std::cout << " at " << m_rps << " Million RPS " << std::endl;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
#include <gtest/gtest.h>
|
||||
#include <fstream>
|
||||
#include "../lib/http/request.hpp"
|
||||
#include <boost/beast.hpp>
|
||||
#include <fstream>
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
TEST(unit_tests, single_request_parse) {
|
||||
TEST(unit_tests, single_request_parse)
|
||||
{
|
||||
std::ifstream t("./test_files/test_request.http");
|
||||
std::stringstream buffer;
|
||||
buffer << t.rdbuf();
|
||||
|
@ -11,7 +12,7 @@ TEST(unit_tests, single_request_parse) {
|
|||
std::string raw_req = buffer.str();
|
||||
std::string expected = buffer.str();
|
||||
|
||||
anthracite::http::request req (raw_req, "0.0.0.0");
|
||||
anthracite::http::request req(raw_req, "0.0.0.0");
|
||||
|
||||
ASSERT_EQ(expected, req.to_string());
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue