@@ -78,6 +78,8 @@ static void read_file(const std::string &path, std::string &out) {
7878 fs.read (&out[0 ], static_cast <std::streamsize>(size));
7979}
8080
81+ #if 0
82+
8183class UnixSocketTest : public ::testing::Test {
8284protected:
8385 void TearDown() override { std::remove(pathname_.c_str()); }
@@ -11172,3 +11174,51 @@ TEST(HeaderSmugglingTest, ChunkedTrailerHeadersMerged) {
1117211174 std::string res;
1117311175 ASSERT_TRUE(send_request(1, req, &res));
1117411176}
11177+ #endif
11178+
11179+ void performance_test (const char *host) {
11180+ auto port = 1234 ;
11181+
11182+ Server svr;
11183+
11184+ svr.Get (" /benchmark" , [&](const Request & /* req*/ , Response &res) {
11185+ res.set_content (" Benchmark Response" , " text/plain" );
11186+ });
11187+
11188+ auto listen_thread = std::thread ([&]() { svr.listen (host, port); });
11189+ auto se = detail::scope_exit ([&] {
11190+ svr.stop ();
11191+ listen_thread.join ();
11192+ ASSERT_FALSE (svr.is_running ());
11193+ });
11194+
11195+ svr.wait_until_ready ();
11196+
11197+ Client cli (host, port);
11198+
11199+ auto start = std::chrono::high_resolution_clock::now ();
11200+
11201+ auto res = cli.Get (" /benchmark" );
11202+ ASSERT_TRUE (res);
11203+ EXPECT_EQ (StatusCode::OK_200, res->status );
11204+
11205+ auto end = std::chrono::high_resolution_clock::now ();
11206+
11207+ auto elapsed =
11208+ std::chrono::duration_cast<std::chrono::milliseconds>(end - start)
11209+ .count ();
11210+
11211+ #ifdef _WIN32
11212+ // Windows has higher timer granularity and scheduling overhead
11213+ // Typical Windows timer resolution is ~15.6ms (64Hz)
11214+ EXPECT_LE (elapsed, 30 ) << " Performance is too slow: " << elapsed
11215+ << " ms (Issue #1777)" ;
11216+ #else
11217+ EXPECT_LE (elapsed, 5 ) << " Performance is too slow: " << elapsed
11218+ << " ms (Issue #1777)" ;
11219+ #endif
11220+ }
11221+
11222+ TEST (BenchmarkTest, localhost) { performance_test (" localhost" ); }
11223+
11224+ TEST (BenchmarkTest, v6) { performance_test (" ::1" ); }
0 commit comments