benchmarks: configure number of env variables via $2

This commit is contained in:
DavHau 2023-08-09 00:44:34 +02:00
parent 01496bcc72
commit 41e2993c31
3 changed files with 44 additions and 17 deletions

View File

@ -1,7 +1,8 @@
#!/usr/bin/env bash
set -eou pipefail
export NUM_PKGS=${1:-1000}
export NUM_PKGS=${1:-100}
export NUM_VARS=${2:-100}
# measure date ini milliseconds
echo -e "\nBenchmarking ${NUM_PKGS}x builtins.derivaton via pkg-funcs"

View File

@ -14,16 +14,25 @@
callModule = module: (_callModule module).config.public;
numPkgs = lib.toInt (builtins.getEnv "NUM_PKGS");
numVars = lib.toInt (builtins.getEnv "NUM_VARS");
pkg-funcs = lib.genAttrs (map toString (lib.range 0 numPkgs)) (
num:
derivation {
name = "hello-${num}";
version = "2.12.1";
system = "x86_64-linux";
builder = "/bin/sh";
args = ["sh" "-c" "echo hello-${num} > $out"];
}
derivation (
{
name = "hello-${num}";
version = "2.12.1";
system = "x86_64-linux";
builder = "/bin/sh";
args = ["sh" "-c" "echo hello-${num} > $out"];
}
# generate env variables
// (
lib.genAttrs (map toString (lib.range 0 numVars)) (
num: "value-${num}"
)
)
)
);
modules = lib.genAttrs (map toString (lib.range 0 numPkgs)) (
@ -39,6 +48,10 @@
builder = "/bin/sh";
args = ["sh" "-c" "echo hello-${num} > $out"];
};
# generate env variables
env = lib.genAttrs (map toString (lib.range 0 numVars)) (
num: "value-${num}"
);
}
);
in {

View File

@ -14,18 +14,27 @@
callModule = module: (_callModule module).config.public;
numPkgs = lib.toInt (builtins.getEnv "NUM_PKGS");
numVars = lib.toInt (builtins.getEnv "NUM_VARS");
pkg-funcs = lib.genAttrs (map toString (lib.range 0 numPkgs)) (
num:
nixpkgs.stdenv.mkDerivation rec {
pname = "hello-${num}";
version = "2.12.1";
src = nixpkgs.fetchurl {
url = "mirror://gnu/hello/hello-${version}.tar.gz";
sha256 = "sha256-jZkUKv2SV28wsM18tCqNxoCZmLxdYH2Idh9RLibH2yA=";
};
doCheck = false;
}
nixpkgs.stdenv.mkDerivation (
rec {
pname = "hello-${num}";
version = "2.12.1";
src = nixpkgs.fetchurl {
url = "mirror://gnu/hello/hello-${version}.tar.gz";
sha256 = "sha256-jZkUKv2SV28wsM18tCqNxoCZmLxdYH2Idh9RLibH2yA=";
};
doCheck = false;
}
# generate env variables
// (
lib.genAttrs (map toString (lib.range 0 numVars)) (
num: "value-${num}"
)
)
)
);
modules = lib.genAttrs (map toString (lib.range 0 numPkgs)) (num:
@ -42,6 +51,10 @@
sha256 = "sha256-jZkUKv2SV28wsM18tCqNxoCZmLxdYH2Idh9RLibH2yA=";
};
};
# generate env variables
env = lib.genAttrs (map toString (lib.range 0 numVars)) (
num: "value-${num}"
);
});
in {
inherit