wrk with LuaJIT
Here is an example of the script get_visits.lua
method="GET"
path = "/v1/analytics/visitsPerLocation?period=P7D&startDate=2014-8-11+00:00:00&tag=mall&type=visits"
request = function()
wrk.headers["Authorization"] = "bHBhdXRoX3VzZXJfaWQ9YWRtaW5Ac2lsbHljYXQuY29tLGxwYXV0aF91c2VyX3R5cGU9QVBJLGxwYXV0aF9zaWduYXR1cmU9NzIzMmYyM2NiZGY3YjRhNmJlZWU2MTYxOGNiYjhlNDlkNmZiN2RhZjIwODFhMjA2NWI2YTljMTUxNTRhNGE1ZixscGF1dGhfdGltZXN0YW1wPTEsbHBhdXRoX3ZlcnNpb249MS4w"
return wrk.format(method, path)
end
response = function(status, headers, body)
-- print(body)
end
Here is the command line to run the script>
>wrk -c 50 -t 8 -d 30s -s ./get_visits.lua http://localhost:5050
It will generate a report as follow:
Running 1m test @ http://sillycat.console.local.digby.com:5050
8 threads and 100 connections
Thread Stats
Avg Stdev Max +/- Stdev
Latency 165.23ms 243.01ms 1.88s 92.41%
Req/Sec 86.35 24.02 120.00 77.93%
40901 requests in 1.00m, 19.74MB read
Requests/sec: 681.50
Transfer/sec: 336.76KB
The first Req/Sec is based on thread.
The final Request/sec is based on all the threads.
References:
http://luajit.org/install.html
https://github.com/wg/wrk
wrk
http://sillycat.iteye.com/blog/2026879
lua
http://sillycat.iteye.com/blog/1460991
http://sillycat.iteye.com/blog/1460997
Some examples
https://github.com/wg/wrk/tree/master/scripts
https://github.com/timotta/wrk-scripts
https://olegdb.org/blog/0002_Benchmarking.html