@@ -3368,14 +3368,16 @@ TEST_F(ServerTest, GetMethod200) {
33683368 EXPECT_EQ (" Hello World!" , res->body );
33693369}
33703370
3371- TEST (BenchmarkTest, SimpleGetPerformance) {
3371+ void performance_test (const char *host) {
3372+ auto port = 1234 ;
3373+
33723374 Server svr;
33733375
33743376 svr.Get (" /benchmark" , [&](const Request & /* req*/ , Response &res) {
33753377 res.set_content (" Benchmark Response" , " text/plain" );
33763378 });
33773379
3378- auto listen_thread = std::thread ([&svr ]() { svr.listen (" localhost " , PORT ); });
3380+ auto listen_thread = std::thread ([&]() { svr.listen (host, port ); });
33793381 auto se = detail::scope_exit ([&] {
33803382 svr.stop ();
33813383 listen_thread.join ();
@@ -3384,7 +3386,7 @@ TEST(BenchmarkTest, SimpleGetPerformance) {
33843386
33853387 svr.wait_until_ready ();
33863388
3387- Client cli (" localhost " , PORT );
3389+ Client cli (host, port );
33883390
33893391 const int NUM_REQUESTS = 50 ;
33903392 const int MAX_AVERAGE_MS = 5 ;
@@ -3405,13 +3407,18 @@ TEST(BenchmarkTest, SimpleGetPerformance) {
34053407 .count ();
34063408 double avg_ms = static_cast <double >(total_ms) / NUM_REQUESTS;
34073409
3408- std::cout << " Standalone: " << NUM_REQUESTS << " requests in " << total_ms
3409- << " ms (avg: " << avg_ms << " ms)" << std::endl;
3410+ std::cout << " Peformance test at \" " << host << " \" : " << NUM_REQUESTS
3411+ << " requests in " << total_ms << " ms (avg: " << avg_ms << " ms)"
3412+ << std::endl;
34103413
34113414 EXPECT_LE (avg_ms, MAX_AVERAGE_MS)
3412- << " Standalone test too slow: " << avg_ms << " ms (Issue #1777)" ;
3415+ << " Performance is too slow: " << avg_ms << " ms (Issue #1777)" ;
34133416}
34143417
3418+ TEST (BenchmarkTest, localhost) { performance_test (" localhost" ); }
3419+
3420+ TEST (BenchmarkTest, v6) { performance_test (" ::1" ); }
3421+
34153422TEST_F (ServerTest, GetEmptyFile) {
34163423 auto res = cli_.Get (" /empty_file" );
34173424 ASSERT_TRUE (res);
0 commit comments