lol
1{ nixpkgs, pkgs }:
2
3with pkgs;
4
5runCommand "nixpkgs-metrics"
6 { buildInputs = [ nix time ];
7 requiredSystemFeatures = [ "benchmark" ];
8 }
9 ''
10 export NIX_DB_DIR=$TMPDIR
11 export NIX_STATE_DIR=$TMPDIR
12 nix-store --init
13
14 mkdir -p $out/nix-support
15 touch $out/nix-support/hydra-build-products
16
17 run() {
18 local name="$1"
19 shift
20
21 echo "running $@"
22 NIX_SHOW_STATS=1 time "$@" 2>&1 > /dev/null | tee stats
23
24 cat stats
25
26 x=$(sed -e 's/.*time elapsed: \([0-9\.]\+\).*/\1/ ; t ; d' stats)
27 [[ -n $x ]] || exit 1
28 echo "$name.time $x s" >> $out/nix-support/hydra-metrics
29
30 x=$(sed -e 's/.* \([0-9]\+\)maxresident.*/\1/ ; t ; d' stats)
31 [[ -n $x ]] || exit 1
32 echo "$name.maxresident $x KiB" >> $out/nix-support/hydra-metrics
33
34 x=$(sed -e 's/.*total allocations: \([0-9]\+\) bytes.*/\1/ ; t ; d' stats)
35 [[ -n $x ]] || exit 1
36 echo "$name.allocations $x B" >> $out/nix-support/hydra-metrics
37
38 x=$(sed -e 's/.*values allocated count: \([0-9]\+\).*/\1/ ; t ; d' stats)
39 [[ -n $x ]] || exit 1
40 echo "$name.values $x" >> $out/nix-support/hydra-metrics
41 }
42
43 run nixos.smallContainer nix-instantiate --dry-run ${nixpkgs}/nixos/release.nix \
44 -A closures.smallContainer.x86_64-linux --show-trace
45 run nixos.kde nix-instantiate --dry-run ${nixpkgs}/nixos/release.nix \
46 -A closures.kde.x86_64-linux --show-trace
47 run nixos.lapp nix-instantiate --dry-run ${nixpkgs}/nixos/release.nix \
48 -A closures.lapp.x86_64-linux --show-trace
49 run nix-env.qa nix-env -f ${nixpkgs} -qa
50 run nix-env.qaDrv nix-env -f ${nixpkgs} -qa --drv-path --meta --xml
51
52 export GC_INITIAL_HEAP_SIZE=128k
53 run nix-env.qaAggressive nix-env -f ${nixpkgs} -qa
54 run nix-env.qaDrvAggressive nix-env -f ${nixpkgs} -qa --drv-path --meta --xml
55
56 lines=$(find ${nixpkgs} -name "*.nix" -type f | xargs cat | wc -l)
57 echo "loc $lines" >> $out/nix-support/hydra-metrics
58 ''