Skip to content

Commit 8b8f2ff

Browse files
committed
bench: add R scripts for plotting WebAssembly function and section sizes
1 parent d99cfc5 commit 8b8f2ff

File tree

2 files changed

+74
-0
lines changed

2 files changed

+74
-0
lines changed

bench/function-size.r

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#!/usr/bin/env Rscript
2+
3+
# Usage:
4+
#
5+
# ./function-size.r function-size.csv
6+
#
7+
# Output will be placed in SVG files.
8+
9+
library(ggplot2)
10+
11+
args <- commandArgs(trailingOnly = TRUE)
12+
13+
data <- read.table(args[1], header = TRUE, sep = ",")
14+
15+
thePlot <- ggplot(data,
16+
aes(x = reorder(Function, -Size),
17+
y = data$Size,
18+
fill = data$Function)) +
19+
geom_bar(stat="identity") +
20+
theme(legend.position = "none",
21+
axis.text.x = element_text(angle = 67.5, hjust = 1)) +
22+
ggtitle("WebAssembly Code Size by Function") +
23+
labs(y = "Code Size (bytes)",
24+
x = "Function")
25+
26+
ggsave(plot = thePlot,
27+
file = "function-size.svg",
28+
device = "svg")
29+
30+
crateData <- aggregate(. ~ Crate, data = data, sum)
31+
print(crateData)
32+
33+
thePlot <- ggplot(crateData,
34+
aes(x = reorder(crateData$Crate, -crateData$Size),
35+
y = crateData$Size,
36+
fill = crateData$Crate)) +
37+
geom_bar(stat="identity") +
38+
theme(legend.position = "none",
39+
axis.text.x = element_text(angle = 45, hjust = 1)) +
40+
ggtitle("WebAssembly Code Size by Crate") +
41+
labs(y = "Code Size (bytes)",
42+
x = "Crate")
43+
44+
ggsave(plot = thePlot,
45+
file = "crate-size.svg",
46+
device = "svg")

bench/section-size.r

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/usr/bin/env Rscript
2+
3+
# Usage:
4+
#
5+
# ./section-size.r section-sizes.csv
6+
#
7+
# Output will be placed in SVG files.
8+
9+
library(ggplot2)
10+
11+
args <- commandArgs(trailingOnly = TRUE)
12+
13+
data <- read.table(args[1], header = TRUE, sep = ",")
14+
15+
thePlot <- ggplot(data,
16+
aes(x = reorder(Section, -Size),
17+
y = data$Size,
18+
fill = data$Section)) +
19+
geom_bar(stat="identity") +
20+
theme(legend.position = "none",
21+
axis.text.x = element_text(angle = 67.5, hjust = 1)) +
22+
ggtitle("WebAssembly Size by Section") +
23+
labs(y = "Size (bytes)",
24+
x = "Section")
25+
26+
ggsave(plot = thePlot,
27+
file = "section-sizes.svg",
28+
device = "svg")

0 commit comments

Comments
 (0)