@@ -46,11 +46,16 @@ public static void loadTest(final long intervalPerThread) {
46
46
sock .connect (new InetSocketAddress (3030 ));
47
47
final var in = new BufferedInputStream (sock .getInputStream ());
48
48
final var out = new BufferedOutputStream (sock .getOutputStream ());
49
- final var json = """
50
- {"jsonrpc": "2.0", "method": "subtract", "params": [42, 23], "id": 1}""" .trim ();
51
- final var bytes = json .getBytes ();
49
+
52
50
final var buff = new byte [512 ];
53
51
while (flag .getOpaque ()) {
52
+ final var json = """
53
+ {"jsonrpc": "2.0", "method": "subtract", "params": {"goal": %d, "str": "%s"}, "id": %d}""" .formatted (
54
+ ThreadLocalRandom .current ().nextInt (Integer .MAX_VALUE ),
55
+ genStr (),
56
+ ThreadLocalRandom .current ().nextInt (Integer .MAX_VALUE )
57
+ ).trim ();
58
+ final var bytes = json .getBytes ();
54
59
out .write (bytes );
55
60
out .flush ();
56
61
in .read (buff );
@@ -61,6 +66,17 @@ public static void loadTest(final long intervalPerThread) {
61
66
}
62
67
}
63
68
69
+ public static String genStr () {
70
+ int leftLimit = 97 ; // letter 'a'
71
+ int rightLimit = 122 ; // letter 'z'
72
+ int targetStringLength = 10 ;
73
+
74
+ return ThreadLocalRandom .current ().ints (leftLimit , rightLimit + 1 )
75
+ .limit (targetStringLength )
76
+ .collect (StringBuilder ::new , StringBuilder ::appendCodePoint , StringBuilder ::append )
77
+ .toString ();
78
+ }
79
+
64
80
public static void sleepSmooth (final long t ) {
65
81
try {
66
82
int n = ThreadLocalRandom .current ().nextInt (0 , 15 );
0 commit comments