Created
January 3, 2020 00:26
-
-
Save mw2q/5fcdc5823b38a4163b3758b28fe96288 to your computer and use it in GitHub Desktop.
post processing dbt2 mix.log with julia
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env julia | |
using Printf | |
using Statistics | |
function process(mixfile::String) | |
ctime0 = missing | |
RampupTime = 0 | |
StartTime = missing | |
SteadyStateTime = missing | |
errors = 0 | |
commits = Dict() | |
rollbacks = Dict() | |
response = Dict() | |
TotalTransactions = 0 | |
for i in ["d", "n", "o", "p", "s"] | |
commits[i] = 0 | |
rollbacks[i] = 0 | |
response[i] = Float64[] | |
end | |
f = open(mixfile) | |
for line in eachline(f) | |
s = split(line, ",") | |
if ismissing(ctime0) | |
ctime0 = parse(Int64, s[1]) | |
end | |
if s[2] == "START" | |
StartTime = parse(Int64, s[1]) | |
RampupTime = StartTime - ctime0 | |
for i in ["d", "n", "o", "p", "s"] | |
commits[i] = 0 | |
rollbacks[i] = 0 | |
response[i] = Float64[] | |
TotalTransactions = 0 | |
end | |
continue | |
end | |
if (s[2] == "TERMINATED") | |
SteadyStateTime = parse(Int64,s[1]) - StartTime | |
break | |
end | |
if s[3] == "C" | |
append!(response[s[2]], parse(Float64,s[4])) | |
commits[s[2]] += 1 | |
TotalTransactions += 1 | |
elseif s[3] == "R" | |
rollbacks[s[2]] += 1 | |
TotalTransactions += 1 | |
elseif s[3] == "E" | |
errors += 1 | |
end | |
end | |
TransactionNames = Dict( | |
"d" => "Delivery", | |
"n" => "New Order", | |
"o" => "Order Status", | |
"p" => "Payment", | |
"s" => "Stock Level" | |
) | |
@printf(" Response Time (s)\n") | |
@printf(" Transaction %% Average : 90th %% Total") | |
@printf(" Rollbacks %%\n") | |
@printf("------------ ----- --------------------- ----------- ") | |
@printf("--------------- -----\n") | |
for i in ["d", "n", "o", "p", "s"] | |
@printf("%12s %5.2f %9.3f : %9.3f %11d %15d %5.2f\n", | |
TransactionNames[i], | |
(commits[i] + rollbacks[i]) / TotalTransactions * 100, | |
mean(response[i]), quantile(response[i], 0.9), commits[i], | |
rollbacks[i], | |
rollbacks[i] / (commits[i] + rollbacks[i]) * 100) | |
end | |
@printf("------------ ----- --------------------- ----------- ") | |
@printf("--------------- -----\n") | |
@printf("%0.2f new-order transactions per minute (NOTPM)\n", | |
commits["n"] / (SteadyStateTime / 60)) | |
@printf("%0.1f minute duration\n", SteadyStateTime / 60) | |
@printf("%d total unknown errors\n", errors) | |
@printf("%0.1f seconds(s) ramping up\n", RampupTime) | |
end | |
mixfile = ARGS[1] | |
process(mixfile) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment