Created
April 2, 2017 06:19
-
-
Save pgilad/7af196f704acc2529af4d51c1803e7da to your computer and use it in GitHub Desktop.
Percentiles plot using R
This file contains hidden or 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
library("ggplot2") | |
sample.jtl <- read.csv("~/repos/work/csv-percentiles/sample.csv") | |
sample.jtl$ts <- as.POSIXct(sample.jtl$ts / 1000, origin="1970-01-01") | |
interval_size <- '5 sec' | |
wanted_percentiles <- c(0.5, 0.9, 0.95, 0.99) | |
get_quantiles <- function(items) { | |
yy <- quantile(items, wanted_percentiles) | |
return (yy) | |
} | |
r <- aggregate(t ~ cut(ts, interval_size), sample.jtl, get_quantiles) | |
names(r) <- c("ts", "t") | |
df <- as.data.frame(r$t) | |
df$ts <- r$ts | |
df$threshold <- rep(300, length(df$ts)) | |
df$ts <- as.POSIXct(df$ts) | |
ggplot(df, aes(x = ts)) + | |
geom_line(aes(y = `99%`, col="99%")) + | |
geom_line(aes(y = `95%`, col="95%")) + | |
geom_line(aes(y = `90%`, col="90%")) + | |
geom_line(aes(y = `50%`, col="50%")) + | |
geom_line(aes(y = threshold, col="threshold")) + | |
labs(x = "Time", y = "Response Time (ms)") + | |
ggtitle("Response Time percentiles over time in 20 seconds intervals") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey, can you send me the sample.csv file. My email: [email protected]