Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
post processing dbt2 mix.log with r
#!/usr/bin/env Rscript
mixfile = commandArgs(trailingOnly=TRUE)[1]
mix <- read.csv(file=mixfile, header=F)
colnames(mix) <- c('ctime', 'txn', 'status', 'response', 'pthread')
# Get the ctime after the START marker and the ctime before the first
# TERMINATED marker.
start <- mix[1,]$ctime
total_txn <- nrow(mix)
# Calculate the ramp up time.
rampup_time <- max(mix$ctime[mix$txn == "START"]) - start
duration <- min(mix$ctime[mix$txn == "TERMINATED"]) - start
errors <- sum(mix$status == "E")
mix <- mix[(!mix$txn == "START") & (!mix$txn == "TERMINATED") &
(!mix$txn == "R") & (!mix$txn == "E"), ]
cat(" Response Time (s)\n")
cat(paste(" Transaction % Average : 90th % Total ",
"Rollbacks %\n", sep = ""))
cat(paste("------------ ----- --------------------- ----------- ",
"--------------- -----\n", sep = ""))
txn <- c("d", "n", "o", "p", "s")
txn_name <- c("Delivery", "New Order", "Order Status", "Payment",
"Stock Level")
for (i in 1:5) {
t_total <- sum(mix$txn == txn[i])
if (i == 2) {
total_n <- t_total
}
t_rollback <- sum(mix$txn == txn[i] & mix$status == "R")
t_mean <- mean(mix$response[mix$txn == txn[i]])
t_q90 <- quantile(mix$response[mix$txn == txn[i]], .9)
cat(sprintf("%12s %5.2f %9.3f : %9.3f %11d %15d %5.2f\n",
txn_name[i], t_total / total_txn * 100, t_mean, t_q90,
t_total, t_rollback, t_rollback / t_total * 100))
}
cat(paste("------------ ----- --------------------- ----------- ",
"--------------- -----\n", sep = ""))
cat(sprintf("%0.2f new-order transactions per minute (NOTPM)\n",
total_n / (duration / 60)))
cat(sprintf("%0.1f minute duration\n", duration / 60))
cat(sprintf("%d total unknown errors\n", errors))
cat(sprintf("%0.1f seconds(s) ramping up\n", rampup_time))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.