@@ -40,7 +40,7 @@ using namespace std::chrono_literals;
4040constexpr size_t kMaxRpcPayloadSize = 15 * 1024 ;
4141
4242// Default stress test duration in seconds (can be overridden by env var)
43- constexpr int kDefaultStressDurationSeconds = 3600 ; // 1 hour
43+ constexpr int kDefaultStressDurationSeconds = 600 ; // 10mins
4444
4545// Test configuration from environment variables
4646struct RpcStressTestConfig {
@@ -167,20 +167,49 @@ class StressTestStats {
167167 std::map<std::string, int > error_counts_;
168168};
169169
170- // Generate a random string of specified size
170+ // Sample sentences for generating compressible payloads
171+ static const std::vector<std::string> kSampleSentences = {
172+ " The quick brown fox jumps over the lazy dog. " ,
173+ " LiveKit is a real-time communication platform for building video and "
174+ " audio applications. " ,
175+ " RPC allows participants to call methods on remote peers with "
176+ " request-response semantics. " ,
177+ " This stress test measures the performance and reliability of the RPC "
178+ " system under load. " ,
179+ " WebRTC enables peer-to-peer communication for real-time media streaming. " ,
180+ " The payload is compressed using Zstd to reduce bandwidth and improve "
181+ " throughput. " ,
182+ " Data channels provide reliable or unreliable delivery of arbitrary "
183+ " application data. " ,
184+ " Participants can publish audio and video tracks to share media with "
185+ " others in the room. " ,
186+ " The signaling server coordinates connection establishment between peers. " ,
187+ " End-to-end encryption ensures that media content is only accessible to "
188+ " participants. " ,
189+ };
190+
191+ // Generate a payload of specified size using repeating sentences (compressible)
171192std::string generateRandomPayload (size_t size) {
172- static const char charset[] =
173- " 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" ;
174193 static thread_local std::random_device rd;
175194 static thread_local std::mt19937 gen (rd ());
176- static std::uniform_int_distribution<> dis (0 , sizeof (charset) - 2 );
195+ static std::uniform_int_distribution<size_t > dis (0 ,
196+ kSampleSentences .size () - 1 );
177197
178198 std::string result;
179199 result.reserve (size);
180- for (size_t i = 0 ; i < size; ++i) {
181- result += charset[dis (gen)];
200+
201+ // Start with a random sentence to add some variation between payloads
202+ size_t start_idx = dis (gen);
203+
204+ while (result.size () < size) {
205+ // Cycle through sentences starting from a random position
206+ const std::string &sentence =
207+ kSampleSentences [(start_idx + result.size ()) % kSampleSentences .size ()];
208+ result += sentence;
182209 }
183- return result;
210+
211+ // Trim to exact size
212+ return result.substr (0 , size);
184213}
185214
186215// Wait for a remote participant to appear
0 commit comments