This repository has been archived by the owner on Nov 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add R script for analysing log span timings
- Loading branch information
Jordan Mackie
authored and
Jordan Mackie
committed
Mar 11, 2023
1 parent
bca36c4
commit 3bc4c7d
Showing
3 changed files
with
60 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
logs.ndjson | ||
plot.png |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
library(magrittr) | ||
library(ggplot2) | ||
|
||
logs <- jsonlite::stream_in(file("logs.ndjson"), verbose = FALSE) | ||
|
||
parse_duration <- function(s) { | ||
n <- as.numeric(substr(s, 1, nchar(s) - 2)) | ||
ifelse(endsWith(s, "ms"), n, n / 1000) | ||
} | ||
|
||
is_outlier <- function(ms) { | ||
# outliers are greater than 10ms | ||
return(ms > 10) | ||
} | ||
|
||
data <- dplyr::bind_rows( | ||
phase = logs$span$name, | ||
file = logs$span$source_name, | ||
duration_ms = parse_duration(logs$fields$time.busy) | ||
) %>% | ||
dplyr::filter( | ||
phase %in% c("parse_cst", "check_module", "generate_javascript") | ||
) %>% | ||
dplyr::mutate( | ||
phase = dplyr::recode(phase, | ||
parse_cst = "Parse", | ||
check_module = "Typecheck", | ||
generate_javascript = "Codegen" | ||
), | ||
outlier = ifelse(is_outlier(duration_ms), file, as.numeric(NA)) | ||
) | ||
|
||
plot <- ggplot( | ||
data, | ||
aes( | ||
x = factor(phase, levels = c("Parse", "Typecheck", "Codegen")), | ||
y = duration_ms | ||
) | ||
) + | ||
geom_boxplot() + | ||
geom_text(aes(label = outlier), na.rm = TRUE, hjust = -0.1, size = 3) + | ||
xlab("Phase") + | ||
ylab("Time (milliseconds)") | ||
|
||
ggsave("plot.png", plot = plot) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
let pkgs = import ../../nixpkgs.nix { }; | ||
in pkgs.mkShell { | ||
buildInputs = [ | ||
(pkgs.rWrapper.override { | ||
packages = with pkgs.rPackages; [ | ||
languageserver | ||
jsonlite | ||
dplyr | ||
ggplot2 | ||
]; | ||
}) | ||
]; | ||
} |