Last active
August 23, 2018 14:08
-
-
Save thefloweringash/da209835eac46f4fdff8bff405b72d3a to your computer and use it in GitHub Desktop.
metrics
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
$ cat metrics.nix | |
with (import <nixpkgs> {}); | |
runCommand "test-metrics" {} '' | |
performance-metrics() { | |
thingname=$1 | |
shift | |
if [ -n "${enablePhaseMetrics:-}" ]; then | |
TIMEFORMAT="time.$thingname.user %U | |
time.$thingname.system %S | |
time.$thingname.real %R" | |
exec {fd}<&2; time ( $@ 2>&$fd; ) 2>> $out/metrics; exec {fd}<&- | |
else | |
"$@" | |
fi | |
} | |
mkdir $out | |
performance-metrics "simple-echo" echo hello | |
'' | |
$ nix-build metrics.nix | |
these derivations will be built: | |
/nix/store/npgf9igg0rg3d0njnbvxz0g9935301mf-test-metrics.drv | |
building '/nix/store/npgf9igg0rg3d0njnbvxz0g9935301mf-test-metrics.drv'... | |
hello | |
/nix/store/mvy92i4hsncjwrz3lq6bmwcgz47nbpyr-test-metrics | |
$ cat result/metrics | |
time.simple-echo.user 0.000 | |
time.simple-echo.system 0.000 | |
time.simple-echo.real 0.000 | |
$ nix-info | |
system: "x86_64-darwin", multi-user?: yes, version: nix-env (Nix) 2.0.4, channels(me): "darwin, nixpkgs-18.09pre149653.dc1b036c962", channels(root): "", nixpkgs: /Users/me/.nix-defexpr/channels/nixpkgs |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment