[PATCH 1 of 5] Tests: improved proxy_unfinished.t performance

Maxim Dounin mdounin at mdounin.ru
Sat Jul 19 03:15:05 UTC 2025


# HG changeset patch
# User Maxim Dounin <mdounin at mdounin.ru>
# Date 1752891869 -10800
#      Sat Jul 19 05:24:29 2025 +0300
# Node ID b04d3b7129f628b1f8c82701b740d333d7bf60dc
# Parent  0b27b42aef05eebd9d180c7ada585ea6ae3da538
Tests: improved proxy_unfinished.t performance.

There is no real reasons to use "for (1 .. 10000) { print ... }" loops
in the test server, yet they require a lot of CPU, leading to occasional
test failures on slow hosts.  Accordingly, such constructs were changed
to prints with large buffers instead.

diff --git a/proxy_unfinished.t b/proxy_unfinished.t
--- a/proxy_unfinished.t
+++ b/proxy_unfinished.t
@@ -216,9 +216,7 @@ sub http_daemon {
 				"Cache-Control: max-age=300" . CRLF .
 				"Connection: close" . CRLF .
 				CRLF;
-			for (1 .. 10000) {
-				print $client ("X" x 98) . CRLF;
-			}
+			print $client (("X" x 98) . CRLF) x 10000;
 			print $client "unfinished" . CRLF;
 
 		} elsif ($uri eq '/big/ok') {
@@ -228,9 +226,7 @@ sub http_daemon {
 				"Cache-Control: max-age=300" . CRLF .
 				"Connection: close" . CRLF .
 				CRLF;
-			for (1 .. 10000) {
-				print $client ("X" x 98) . CRLF;
-			}
+			print $client (("X" x 98) . CRLF) x 10000;
 			print $client "finished" . CRLF;
 
 		} elsif ($uri eq '/chunked') {



More information about the nginx-devel mailing list