-
Notifications
You must be signed in to change notification settings - Fork 0
/
replay.coffee
38 lines (31 loc) · 914 Bytes
/
replay.coffee
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
fs = require("fs")
http = require("http")
url = require("url")
exec = require("child_process").exec
exectimer = require("exectimer")
# Parse urls file
urls = fs.readFileSync("urls.txt").toString().split("\n")
reqs =
total: 0
x2xx: 0
s4xx: 0
s5xx: 0
stats = ->
timer = exectimer.timers.curl
console.log "Number of requests: #{JSON.stringify(reqs)}"
console.log " average: " + timer.parse(timer.mean())
console.log " median: " + timer.parse(timer.median())
console.log " min: " + timer.parse(timer.min())
bench = (curlCmd) ->
reqs.total += 1
tick = new exectimer.Tick("curl")
tick.start()
child = exec(curlCmd, (error, stdout, stderr) ->
tick.stop()
reqs.x2xx += 1
# console.log "stdout: " + stdout
# console.log "stderr: " + stderr
# console.log "exec error: " + error if error isnt null
stats() if reqs.total is reqs.x2xx
)
bench url for url in urls