forked from Xerxes-2/clewdr
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathload_test.sh
More file actions
executable file
·74 lines (59 loc) · 1.88 KB
/
load_test.sh
File metadata and controls
executable file
·74 lines (59 loc) · 1.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/bin/bash
# Base URL of your proxy endpoint
BASE_URL="http://127.0.0.1:8484/v1/v1beta/models/gemini-2.5-flash-preview-04-17"
API_KEY="1145141919870"
# Function to handle each request in a separate process
send_request() {
local request_id=$1
# Generate random number (0-9) for content
local random_num=$((RANDOM % 10))
# Randomly choose between streaming and non-streaming endpoint
local use_streaming=$((RANDOM % 2))
local endpoint
if [ $use_streaming -eq 1 ]; then
endpoint="streamGenerateContent?key=$API_KEY&alt=sse"
local mode="streaming"
else
endpoint="generateContent?key=$API_KEY"
local mode="non-streaming"
fi
# Full URL for this request
local full_url="$BASE_URL:$endpoint"
# Create payload with random number in content
local payload='{
"contents": [
{
"parts": [
{
"text": "I am testing my API proxy, tell me a random fact about the number '"$random_num"', longer better."
}
]
}
],
"generationConfig": {
"temperature": 0.7,
"topP": 0.95,
"topK": 40
}
}'
echo "Request $request_id started at $(date) - Mode: $mode, Number: $random_num"
# Create a unique log file for this request
local log_file="request_${request_id}_${mode}_${random_num}.log"
# Send the request and save the response
curl -X POST \
-H "Content-Type: application/json" \
-d "$payload" \
"$full_url" >"$log_file" 2>&1
echo "Request $request_id completed at $(date), response saved to $log_file"
}
# Counter for request IDs
request_id=1
# Loop to send requests every 1 second
while true; do
# Launch request in background but still capture output
send_request $request_id &
# Increment request counter
((request_id++))
# Wait for 1 second before the next request
sleep 1
done