forked from rarias/bscpkgs
WIP: postprocessing pipeline
Now each run is executed in a independent folder
This commit is contained in:
@@ -1,21 +1,30 @@
|
||||
library(ggplot2)
|
||||
library(dplyr)
|
||||
library(scales)
|
||||
library(jsonlite)
|
||||
|
||||
# Load the dataset
|
||||
#df=read.table("/nix/store/zcyazjbcjn2lhxrpa3bs5y7rw3bbcgnr-plot/data.csv",
|
||||
df=read.table("data.csv",
|
||||
col.names=c("variant", "blocksize", "time"))
|
||||
args=commandArgs(trailingOnly=TRUE)
|
||||
|
||||
# Read the timetable from args[1]
|
||||
input_file = "timetable.json.gz"
|
||||
if (length(args)>0) { input_file = args[1] }
|
||||
|
||||
# Load the dataset in NDJSON format
|
||||
dataset = jsonlite::stream_in(file(input_file)) %>%
|
||||
jsonlite::flatten()
|
||||
|
||||
# We only need the cpu bind, blocksize and time
|
||||
df = select(dataset, config.freeCpu, config.blocksize, time) %>%
|
||||
rename(blocksize=config.blocksize, freeCpu=config.freeCpu)
|
||||
|
||||
# Use the blocksize as factor
|
||||
df$blocksize = as.factor(df$blocksize)
|
||||
df$freeCpu = as.factor(df$freeCpu)
|
||||
|
||||
# Split by malloc variant
|
||||
|
||||
D=df %>% group_by(variant, blocksize) %>%
|
||||
D=df %>% group_by(freeCpu, blocksize) %>%
|
||||
mutate(tnorm = time / median(time) - 1)
|
||||
|
||||
|
||||
bs_unique = unique(df$blocksize)
|
||||
nbs=length(bs_unique)
|
||||
|
||||
@@ -49,7 +58,7 @@ p = ggplot(data=D, aes(x=blocksize, y=tnorm)) +
|
||||
linetype="dashed", color="red") +
|
||||
|
||||
# Draw boxplots
|
||||
geom_boxplot(aes(fill=variant)) +
|
||||
geom_boxplot(aes(fill=freeCpu)) +
|
||||
|
||||
# # Use log2 scale in x
|
||||
# scale_x_continuous(trans=log2_trans(),
|
||||
@@ -64,7 +73,7 @@ p = ggplot(data=D, aes(x=blocksize, y=tnorm)) +
|
||||
theme(legend.position = c(0.85, 0.85)) #+
|
||||
|
||||
# Place each variant group in one separate plot
|
||||
#facet_wrap(~variant)
|
||||
#facet_wrap(~freeCpu)
|
||||
|
||||
|
||||
|
||||
@@ -77,7 +86,7 @@ dev.off()
|
||||
png("scatter.png", width=w*ppi, height=h*ppi, res=ppi)
|
||||
#
|
||||
## Create the plot with the normalized time vs blocksize
|
||||
p = ggplot(D, aes(x=blocksize, y=time, color=variant)) +
|
||||
p = ggplot(D, aes(x=blocksize, y=time, color=freeCpu)) +
|
||||
|
||||
labs(x="Block size", y="Time (s)",
|
||||
title="Nbody granularity",
|
||||
@@ -1,67 +0,0 @@
|
||||
{
|
||||
stdenv
|
||||
, gnuplot
|
||||
, jq
|
||||
, garlicTools
|
||||
, resultFromTrebuchet
|
||||
, writeText
|
||||
, rWrapper
|
||||
, rPackages
|
||||
|
||||
# The two results to be compared
|
||||
, resDefault
|
||||
, resFreeCpu
|
||||
}:
|
||||
|
||||
with garlicTools;
|
||||
with stdenv.lib;
|
||||
|
||||
let
|
||||
customR = rWrapper.override {
|
||||
packages = with rPackages; [ tidyverse ];
|
||||
};
|
||||
|
||||
plotScript = ./plot.R;
|
||||
|
||||
in stdenv.mkDerivation {
|
||||
name = "plot";
|
||||
buildInputs = [ jq gnuplot customR ];
|
||||
preferLocalBuild = true;
|
||||
dontPatchShebangs = true;
|
||||
|
||||
src = ./.;
|
||||
|
||||
buildPhase = ''
|
||||
echo default = ${resDefault}
|
||||
echo freeCpu = ${resFreeCpu}
|
||||
|
||||
substituteAllInPlace plot.R
|
||||
sed -ie "s:@expResult@:$out:g" plot.R
|
||||
|
||||
for unit in ${resDefault}/*/*; do
|
||||
name=$(basename $unit)
|
||||
log="$unit/stdout.log"
|
||||
conf="$unit/garlic_config.json"
|
||||
bs=$(jq .blocksize $conf)
|
||||
awk "/^time /{print \"default\", $bs, \$2}" $log >> data.csv
|
||||
done
|
||||
|
||||
for unit in ${resFreeCpu}/*/*; do
|
||||
name=$(basename $unit)
|
||||
log="$unit/stdout.log"
|
||||
conf="$unit/garlic_config.json"
|
||||
bs=$(jq .blocksize $conf)
|
||||
awk "/^time /{print \"freeCpu\", $bs, \$2}" $log >> data.csv
|
||||
done
|
||||
|
||||
Rscript plot.R
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
mkdir $out
|
||||
ln -s ${resFreeCpu} $out/resFreeCpu
|
||||
ln -s ${resDefault} $out/resDefault
|
||||
cp *.png $out/
|
||||
cp *.csv $out/
|
||||
'';
|
||||
}
|
||||
@@ -1,20 +1,31 @@
|
||||
library(ggplot2)
|
||||
library(dplyr)
|
||||
library(scales)
|
||||
library(jsonlite)
|
||||
|
||||
# Load the dataset
|
||||
df=read.table("/nix/store/vvfcimwp8mkv6kc5fs3rbyjy8grgpmmb-plot/data.csv",
|
||||
col.names=c("variant", "blocksize", "time"))
|
||||
args=commandArgs(trailingOnly=TRUE)
|
||||
|
||||
# Read the timetable from args[1]
|
||||
input_file = "timetable.json.gz"
|
||||
if (length(args)>0) { input_file = args[1] }
|
||||
|
||||
# Load the dataset in NDJSON format
|
||||
dataset = jsonlite::stream_in(file(input_file)) %>%
|
||||
jsonlite::flatten()
|
||||
|
||||
# We only need the cpu bind, blocksize and time
|
||||
df = select(dataset, config.enableJemalloc, config.blocksize, time) %>%
|
||||
rename(blocksize=config.blocksize,
|
||||
jemalloc=config.enableJemalloc)
|
||||
|
||||
# Use the blocksize as factor
|
||||
df$blocksize = as.factor(df$blocksize)
|
||||
df$jemalloc = as.factor(df$jemalloc)
|
||||
|
||||
# Split by malloc variant
|
||||
|
||||
D=df %>% group_by(variant, blocksize) %>%
|
||||
D=df %>% group_by(jemalloc, blocksize) %>%
|
||||
mutate(tnorm = time / median(time) - 1)
|
||||
|
||||
|
||||
bs_unique = unique(df$blocksize)
|
||||
nbs=length(bs_unique)
|
||||
|
||||
@@ -35,7 +46,7 @@ p = ggplot(data=D, aes(x=blocksize, y=tnorm)) +
|
||||
# Labels
|
||||
labs(x="Block size", y="Normalized time",
|
||||
title="Nbody normalized time",
|
||||
subtitle="@expResult@") +
|
||||
subtitle=input_file) +
|
||||
|
||||
# Center the title
|
||||
#theme(plot.title = element_text(hjust = 0.5)) +
|
||||
@@ -48,7 +59,7 @@ p = ggplot(data=D, aes(x=blocksize, y=tnorm)) +
|
||||
linetype="dashed", color="red") +
|
||||
|
||||
# Draw boxplots
|
||||
geom_boxplot(aes(fill=variant)) +
|
||||
geom_boxplot(aes(fill=freeCpu)) +
|
||||
|
||||
# # Use log2 scale in x
|
||||
# scale_x_continuous(trans=log2_trans(),
|
||||
@@ -58,10 +69,11 @@ p = ggplot(data=D, aes(x=blocksize, y=tnorm)) +
|
||||
|
||||
theme_bw() +
|
||||
|
||||
theme(plot.subtitle=element_text(size=10)) +
|
||||
|
||||
theme(legend.position = c(0.85, 0.85)) #+
|
||||
|
||||
# Place each variant group in one separate plot
|
||||
#facet_wrap(~variant)
|
||||
|
||||
|
||||
|
||||
@@ -71,22 +83,22 @@ print(p)
|
||||
## Save the png image
|
||||
dev.off()
|
||||
#
|
||||
#png("scatter.png", width=w*ppi, height=h*ppi, res=ppi)
|
||||
png("scatter.png", width=w*ppi, height=h*ppi, res=ppi)
|
||||
#
|
||||
## Create the plot with the normalized time vs blocksize
|
||||
#p = ggplot(D, aes(x=blocksize, y=time, color=variant)) +
|
||||
#
|
||||
# labs(x="Block size", y="Time (s)",
|
||||
# title="Nbody granularity",
|
||||
# subtitle="@expResult@") +
|
||||
# theme_bw() +
|
||||
#
|
||||
# geom_point(shape=21, size=3) +
|
||||
# scale_x_continuous(trans=log2_trans()) +
|
||||
# scale_y_continuous(trans=log2_trans())
|
||||
#
|
||||
## Render the plot
|
||||
#print(p)
|
||||
#
|
||||
## Save the png image
|
||||
#dev.off()
|
||||
p = ggplot(D, aes(x=blocksize, y=time, color=freeCpu)) +
|
||||
|
||||
labs(x="Block size", y="Time (s)",
|
||||
title="Nbody granularity",
|
||||
subtitle=input_file) +
|
||||
theme_bw() +
|
||||
|
||||
geom_point(shape=21, size=3) +
|
||||
#scale_x_continuous(trans=log2_trans()) +
|
||||
scale_y_continuous(trans=log2_trans())
|
||||
|
||||
# Render the plot
|
||||
print(p)
|
||||
|
||||
# Save the png image
|
||||
dev.off()
|
||||
@@ -1,68 +0,0 @@
|
||||
{
|
||||
stdenv
|
||||
, gnuplot
|
||||
, jq
|
||||
, garlicTools
|
||||
, resultFromTrebuchet
|
||||
, writeText
|
||||
, rWrapper
|
||||
, rPackages
|
||||
|
||||
# The two results to be compared
|
||||
, resDefault
|
||||
, resJemalloc
|
||||
}:
|
||||
|
||||
with garlicTools;
|
||||
with stdenv.lib;
|
||||
|
||||
let
|
||||
customR = rWrapper.override {
|
||||
packages = with rPackages; [ tidyverse ];
|
||||
};
|
||||
|
||||
plotScript = ./plot.R;
|
||||
|
||||
in stdenv.mkDerivation {
|
||||
name = "plot";
|
||||
buildInputs = [ jq gnuplot customR ];
|
||||
preferLocalBuild = true;
|
||||
dontPatchShebangs = true;
|
||||
|
||||
inherit resDefault resJemalloc;
|
||||
|
||||
src = ./.;
|
||||
|
||||
buildPhase = ''
|
||||
echo default = ${resJemalloc}
|
||||
echo jemalloc = ${resJemalloc}
|
||||
|
||||
substituteAllInPlace plot.R
|
||||
|
||||
for unit in ${resDefault}/*/*; do
|
||||
name=$(basename $unit)
|
||||
log="$unit/stdout.log"
|
||||
conf="$unit/garlic_config.json"
|
||||
bs=$(jq .blocksize $conf)
|
||||
awk "/^time /{print \"default\", $bs, \$2}" $log >> data.csv
|
||||
done
|
||||
|
||||
for unit in ${resJemalloc}/*/*; do
|
||||
name=$(basename $unit)
|
||||
log="$unit/stdout.log"
|
||||
conf="$unit/garlic_config.json"
|
||||
bs=$(jq .blocksize $conf)
|
||||
awk "/^time /{print \"jemalloc\", $bs, \$2}" $log >> data.csv
|
||||
done
|
||||
|
||||
#Rscript plot.R
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
mkdir $out
|
||||
ln -s ${resJemalloc} $out/resJemalloc
|
||||
ln -s ${resDefault} $out/resDefault
|
||||
#cp *.png $out/
|
||||
cp *.csv $out/
|
||||
'';
|
||||
}
|
||||
@@ -1,62 +0,0 @@
|
||||
{
|
||||
stdenv
|
||||
, gnuplot
|
||||
, jq
|
||||
, experiments
|
||||
, garlicTools
|
||||
, getExpResult
|
||||
, writeText
|
||||
, rWrapper
|
||||
, rPackages
|
||||
}:
|
||||
|
||||
with garlicTools;
|
||||
with stdenv.lib;
|
||||
|
||||
let
|
||||
experiment = builtins.elemAt experiments 0;
|
||||
expResult = getExpResult {
|
||||
garlicTemp = "/tmp/garlic-temp";
|
||||
trebuchetStage = experiment;
|
||||
experimentStage = getExperimentStage experiment;
|
||||
};
|
||||
|
||||
customR = rWrapper.override {
|
||||
packages = with rPackages; [ tidyverse ];
|
||||
};
|
||||
|
||||
plotScript = ./plot.R;
|
||||
|
||||
in stdenv.mkDerivation {
|
||||
name = "plot";
|
||||
buildInputs = [ jq gnuplot customR ];
|
||||
preferLocalBuild = true;
|
||||
dontPatchShebangs = true;
|
||||
|
||||
inherit expResult;
|
||||
|
||||
src = ./.;
|
||||
|
||||
buildPhase = ''
|
||||
echo "using results ${expResult}"
|
||||
|
||||
substituteAllInPlace plot.R
|
||||
|
||||
for unit in ${expResult}/*/*; do
|
||||
name=$(basename $unit)
|
||||
log="$unit/stdout.log"
|
||||
conf="$unit/garlic_config.json"
|
||||
bs=$(jq .blocksize $conf)
|
||||
awk "/^time /{print $bs, \$2}" $log >> data.csv
|
||||
done
|
||||
|
||||
Rscript plot.R
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
mkdir $out
|
||||
ln -s ${expResult} $out/result
|
||||
cp *.png $out/
|
||||
cp data.csv $out/
|
||||
'';
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
{ pkgs ? import ../../default.nix }:
|
||||
|
||||
with pkgs;
|
||||
|
||||
let
|
||||
rWrapper = pkgs.rWrapper.override {
|
||||
packages = with pkgs.rPackages; [ tidyverse ];
|
||||
};
|
||||
in
|
||||
stdenv.mkDerivation {
|
||||
name = "R";
|
||||
|
||||
buildInputs = [ rWrapper ];
|
||||
}
|
||||
Reference in New Issue
Block a user