summary refs log tree commit diff
path: root/pkgs/top-level/metrics.nix
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2016-03-24 17:36:26 +0100
committerEelco Dolstra <eelco.dolstra@logicblox.com>2016-03-24 17:37:17 +0100
commitfab439201e1c48ab8670ee073ab8f5905a2b6c15 (patch)
tree1803ca14e8f042e406eafe2a96c0e2e2fb074033 /pkgs/top-level/metrics.nix
parent63b6498aa08fb72a756a242ec2c93c26e7cded99 (diff)
downloadnixlib-fab439201e1c48ab8670ee073ab8f5905a2b6c15.tar
nixlib-fab439201e1c48ab8670ee073ab8f5905a2b6c15.tar.gz
nixlib-fab439201e1c48ab8670ee073ab8f5905a2b6c15.tar.bz2
nixlib-fab439201e1c48ab8670ee073ab8f5905a2b6c15.tar.lz
nixlib-fab439201e1c48ab8670ee073ab8f5905a2b6c15.tar.xz
nixlib-fab439201e1c48ab8670ee073ab8f5905a2b6c15.tar.zst
nixlib-fab439201e1c48ab8670ee073ab8f5905a2b6c15.zip
Keep track of Nixpkgs/NixOS evaluation statistics
Diffstat (limited to 'pkgs/top-level/metrics.nix')
-rw-r--r--pkgs/top-level/metrics.nix54
1 files changed, 54 insertions, 0 deletions
diff --git a/pkgs/top-level/metrics.nix b/pkgs/top-level/metrics.nix
new file mode 100644
index 000000000000..44cf87f1094e
--- /dev/null
+++ b/pkgs/top-level/metrics.nix
@@ -0,0 +1,54 @@
+{ nixpkgs, pkgs }:
+
+with pkgs;
+
+runCommand "nixpkgs-metrics"
+  { buildInputs = [ nix time ];
+    requiredSystemFeatures = [ "benchmark" ];
+  }
+  ''
+    export NIX_DB_DIR=$TMPDIR
+    export NIX_STATE_DIR=$TMPDIR
+    nix-store --init
+
+    mkdir -p $out/nix-support
+
+    run() {
+      local name="$1"
+      shift
+
+      echo "running $@"
+      NIX_SHOW_STATS=1 time "$@" > /dev/null 2> stats
+
+      cat stats
+
+      x=$(sed -e 's/.*time elapsed: \([0-9\.]\+\).*/\1/ ; t ; d' stats)
+      [[ -n $x ]] || exit 1
+      echo "$name.time $x s" >> $out/nix-support/hydra-metrics
+
+      x=$(sed -e 's/.* \([0-9]\+\)maxresident.*/\1/ ; t ; d' stats)
+      [[ -n $x ]] || exit 1
+      echo "$name.maxresident $x KiB" >> $out/nix-support/hydra-metrics
+
+      x=$(sed -e 's/.*total allocations: \([0-9]\+\) bytes.*/\1/ ; t ; d' stats)
+      [[ -n $x ]] || exit 1
+      echo "$name.allocations $x B" >> $out/nix-support/hydra-metrics
+
+      x=$(sed -e 's/.*values allocated: \([0-9]\+\) .*/\1/ ; t ; d' stats)
+      [[ -n $x ]] || exit 1
+      echo "$name.values $x" >> $out/nix-support/hydra-metrics
+    }
+
+    run nixos.smallContainer nix-instantiate --dry-run ${nixpkgs}/nixos/release.nix -A closures.smallContainer.x86_64-linux
+    run nixos.kde nix-instantiate --dry-run ${nixpkgs}/nixos/release.nix -A closures.kde.x86_64-linux
+    run nixos.lapp nix-instantiate --dry-run ${nixpkgs}/nixos/release.nix -A closures.lapp.x86_64-linux
+    run nix-env.qa nix-env -f ${nixpkgs} -qa
+    run nix-env.qaDrv nix-env -f ${nixpkgs} -qa --drv-path --meta --xml
+
+    export GC_INITIAL_HEAP_SIZE=128k
+    run nix-env.qaAggressive nix-env -f ${nixpkgs} -qa
+    run nix-env.qaDrvAggressive nix-env -f ${nixpkgs} -qa --drv-path --meta --xml
+
+    lines=$(find ${nixpkgs} -name "*.nix" -type f | xargs cat | wc -l)
+    echo "loc $lines" >> $out/nix-support/hydra-metrics
+  ''