functiondone(summary,latency,requests)latency.min-- minimum value seenlatency.max-- maximum value seenlatency.mean-- average value seenlatency.stdev-- standard deviationlatency:percentile(99.0)-- 99th percentile valuelatency(i)-- raw value and countsummary={duration=N,-- run duration in microsecondsrequests=N,-- total completed requestsbytes=N,-- total bytes receivederrors={connect=N,-- total socket connection errorsread=N,-- total socket read errorswrite=N,-- total socket write errorsstatus=N,-- total HTTP status codes > 399timeout=N-- total request timeouts}}
-- example script that demonstrates use of setup() to pass-- data to and from the threadslocalcounter=1localthreads={}functionsetup(thread)thread:set("id",counter)table.insert(threads,thread)counter=counter+1endfunctioninit(args)requests=0responses=0localmsg="thread %d created"print(msg:format(id))endfunctionrequest()requests=requests+1returnwrk.request()endfunctionresponse(status,headers,body)responses=responses+1endfunctiondone(summary,latency,requests)forindex,threadinipairs(threads)dolocalid=thread:get("id")localrequests=thread:get("requests")localresponses=thread:get("responses")localmsg="thread %d made %d requests and got %d responses"print(msg:format(id,requests,responses))endend