mirror of
https://github.com/NixOS/nix.git
synced 2025-11-19 08:49:35 +01:00
[TMP]: Add some benchmarking tools
Not intended to be merged (at least definitely not as it is)
This commit is contained in:
parent
bb06640971
commit
891390d76f
3 changed files with 71 additions and 1 deletions
51
benchmark.sh
Executable file
51
benchmark.sh
Executable file
|
|
@ -0,0 +1,51 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
set -x
|
||||||
|
|
||||||
|
callNix () {
|
||||||
|
nix \
|
||||||
|
--experimental-features "nix-command flakes" \
|
||||||
|
--store /tmp/nix \
|
||||||
|
"$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
callBuild () {
|
||||||
|
callNix \
|
||||||
|
eval --impure --file "$THINGTOBENCH" drvPath \
|
||||||
|
"$@"
|
||||||
|
}
|
||||||
|
getCompletions () {
|
||||||
|
NIX_GET_COMPLETIONS=6 callNix build "github:NixOS/nixpkgs?rev=ad0d20345219790533ebe06571f82ed6b034db31#firef" "$@"
|
||||||
|
}
|
||||||
|
runSearch () {
|
||||||
|
callNix search "github:NixOS/nixpkgs?rev=ad0d20345219790533ebe06571f82ed6b034db31" firefox "$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
noCache () {
|
||||||
|
"$@" --option eval-cache false
|
||||||
|
}
|
||||||
|
coldCache () {
|
||||||
|
if [[ -e ~/.cache/nix/eval-cache-v2 || -e ~/.cache/nix/eval-cache-v3 ]]; then
|
||||||
|
echo "Error: The cache should be clean"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
"$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
run_all () {
|
||||||
|
|
||||||
|
mkdir -p "$out"
|
||||||
|
|
||||||
|
NIX_SHOW_STATS=1 NIX_SHOW_STATS_PATH=$out/eval-stats.json bash $0 noCache callBuild
|
||||||
|
|
||||||
|
hyperfine \
|
||||||
|
--warmup 2 \
|
||||||
|
--export-csv "$out/result.csv" \
|
||||||
|
--export-json "$out/result.json" \
|
||||||
|
--export-markdown "$out/result.md" \
|
||||||
|
--style basic \
|
||||||
|
--prepare '' "bash $0 noCache callBuild"
|
||||||
|
}
|
||||||
|
|
||||||
|
"$@"
|
||||||
|
|
@ -294,6 +294,13 @@
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
nix-benchmarks = prev.runCommandNoCC "nix-benchmarks" {
|
||||||
|
buildInputs = [ final.nix prev.hyperfine ];
|
||||||
|
THINGTOBENCH = ./thingToBench.nix;
|
||||||
|
NIX_PATH="nixpkgs=${prev.path}";
|
||||||
|
} ''
|
||||||
|
bash ${./benchmark.sh} run_all
|
||||||
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
hydraJobs = {
|
hydraJobs = {
|
||||||
|
|
@ -485,7 +492,7 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
packages = forAllSystems (system: {
|
packages = forAllSystems (system: {
|
||||||
inherit (nixpkgsFor.${system}) nix;
|
inherit (nixpkgsFor.${system}) nix nix-benchmarks;
|
||||||
} // nixpkgs.lib.optionalAttrs (builtins.elem system linux64BitSystems) {
|
} // nixpkgs.lib.optionalAttrs (builtins.elem system linux64BitSystems) {
|
||||||
nix-static = let
|
nix-static = let
|
||||||
nixpkgs = nixpkgsFor.${system}.pkgsStatic;
|
nixpkgs = nixpkgsFor.${system}.pkgsStatic;
|
||||||
|
|
|
||||||
12
thingToBench.nix
Normal file
12
thingToBench.nix
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
let
|
||||||
|
# pkgs = (builtins.getFlake "github:NixOS/nixpkgs?rev=ad0d20345219790533ebe06571f82ed6b034db31").legacyPackages.x86_64-linux;
|
||||||
|
pkgs = import <nixpkgs> {};
|
||||||
|
in
|
||||||
|
pkgs.runCommandNoCC "foo" {
|
||||||
|
buildInputs = [
|
||||||
|
pkgs.firefox
|
||||||
|
pkgs.pandoc
|
||||||
|
# pkgs.nixosTests.xfce
|
||||||
|
];
|
||||||
|
}
|
||||||
|
"echo bar > $out"
|
||||||
Loading…
Add table
Add a link
Reference in a new issue