threads = {}
resps = {}
setup = function(thread)
table.insert(threads, thread)
end
response = function(status, headers, body)
if status == 200 then
resps['a'] = 1
end
end
done = function(summary, latency, requests)
for _, thread in ipairs(threads) do
for k, v in pairs(thread:get('resps')) do
print(k, v)
end
end
end
Then:
$ wrk -d 3 -s report.lua ...
a 1
a 1
(Observe it printed keys and values)
$ wrk2 -d 3 -s report.lua ...
1 a
1 a
(Observe pairs swapped around k and v for the table returned by thread.get)
This is based on the latest wrk and wrk2.
FROM buildpack-deps:bionic
RUN apt-get update && apt-get install -yqq libluajit-5.1-dev libssl-dev luajit
WORKDIR /wrk
COPY wrk-4.1.0.tar.gz wrk-4.1.0.tar.gz
RUN tar xfz wrk-4.1.0.tar.gz --strip-components=1
ENV LDFLAGS="-O3 -march=native -flto"
ENV CFLAGS="-I /usr/include/luajit-2.1 $LDFLAGS"
RUN make WITH_LUAJIT=/usr WITH_OPENSSL=/usr -j "$(nproc)"
RUN cp wrk /usr/local/bin
WORKDIR /
COPY wrk2.zip wrk2.zip # downloaded source as zip from github
RUN unzip wrk2.zip
WORKDIR /wrk2-master
ENV LDFLAGS="-O3 -march=native -flto"
ENV CFLAGS="-I /usr/include/luajit-2.1 $LDFLAGS"
RUN make WITH_LUAJIT=/usr WITH_OPENSSL=/usr -j "$(nproc)"
RUN cp wrk /usr/local/bin/wrk2
WORKDIR /wrk
Then:
(Observe it printed keys and values)
(Observe
pairs
swapped around k and v for the table returned bythread.get
)This is based on the latest
wrk
andwrk2
.