feat: add cJSON and SQLite amalgamation source files under deps/
Add the cJSON library (cJSON.c, cJSON.h) and SQLite amalgamation (sqlite3.c, sqlite3.h, sqlite3ext.h, shell.c) as vendored dependencies in the deps/ directory for use by the project build system.
This commit is contained in:
Vendored
+91
@@ -0,0 +1,91 @@
|
||||
// retoor <retoor@molodetz.nl>
|
||||
|
||||
import "websocket" for WebSocket
|
||||
import "io" for Stdout
|
||||
|
||||
var host = "ws://127.0.0.1:8080"
|
||||
var totalMessages = 50000
|
||||
var warmupMessages = 100
|
||||
|
||||
System.print("=== WebSocket Extreme Load Test ===")
|
||||
System.print("Target: %(host)")
|
||||
System.print("Messages: %(totalMessages) (warmup: %(warmupMessages))")
|
||||
System.print("")
|
||||
Stdout.flush()
|
||||
|
||||
var ws = WebSocket.connect(host)
|
||||
System.print("Connected")
|
||||
Stdout.flush()
|
||||
|
||||
var i = 0
|
||||
while (i < warmupMessages) {
|
||||
ws.send("warmup%(i)")
|
||||
ws.receive()
|
||||
i = i + 1
|
||||
}
|
||||
System.print("Warmup complete")
|
||||
Stdout.flush()
|
||||
|
||||
var errors = 0
|
||||
var minTime = 999999
|
||||
var maxTime = 0
|
||||
var totalTime = 0
|
||||
var times = []
|
||||
|
||||
var startTime = System.clock
|
||||
|
||||
i = 0
|
||||
while (i < totalMessages) {
|
||||
var msgStart = System.clock
|
||||
ws.send("msg%(i)")
|
||||
var response = ws.receive()
|
||||
var msgEnd = System.clock
|
||||
var elapsed = msgEnd - msgStart
|
||||
|
||||
if (response == null || !response.isText) {
|
||||
errors = errors + 1
|
||||
} else {
|
||||
times.add(elapsed)
|
||||
totalTime = totalTime + elapsed
|
||||
if (elapsed < minTime) minTime = elapsed
|
||||
if (elapsed > maxTime) maxTime = elapsed
|
||||
}
|
||||
|
||||
if (i > 0 && i % 2000 == 0) {
|
||||
var progress = (i * 100 / totalMessages).floor
|
||||
var currentRate = i / (System.clock - startTime)
|
||||
System.print(" Progress: %(progress) percent (%(currentRate.floor) msg/sec)")
|
||||
Stdout.flush()
|
||||
}
|
||||
|
||||
i = i + 1
|
||||
}
|
||||
|
||||
var endTime = System.clock
|
||||
var totalElapsed = endTime - startTime
|
||||
|
||||
ws.close()
|
||||
|
||||
times.sort()
|
||||
var p50 = times[(times.count * 0.5).floor]
|
||||
var p90 = times[(times.count * 0.9).floor]
|
||||
var p95 = times[(times.count * 0.95).floor]
|
||||
var p99 = times[(times.count * 0.99).floor]
|
||||
var avgTime = totalTime / times.count
|
||||
|
||||
System.print("")
|
||||
System.print("=== Results ===")
|
||||
System.print("Total messages: %(totalMessages)")
|
||||
System.print("Errors: %(errors)")
|
||||
System.print("Total time: %(totalElapsed)s")
|
||||
System.print("Throughput: %((totalMessages / totalElapsed).floor) msg/sec")
|
||||
System.print("")
|
||||
System.print("=== Latency (per message round-trip) ===")
|
||||
System.print("Min: %((minTime * 1000000).floor) us")
|
||||
System.print("Max: %((maxTime * 1000000).floor) us")
|
||||
System.print("Avg: %((avgTime * 1000000).floor) us")
|
||||
System.print("P50: %((p50 * 1000000).floor) us")
|
||||
System.print("P90: %((p90 * 1000000).floor) us")
|
||||
System.print("P95: %((p95 * 1000000).floor) us")
|
||||
System.print("P99: %((p99 * 1000000).floor) us")
|
||||
Stdout.flush()
|
||||
Reference in New Issue
Block a user