mirror of
https://github.com/nix-community/dream2nix.git
synced 2024-11-26 22:31:39 +03:00
benchmarks: pkg-funcs vs. modules
This commit is contained in:
parent
7b96349dd4
commit
deb25a354f
17
misc/benchmarks/benchmark.sh
Executable file
17
misc/benchmarks/benchmark.sh
Executable file
@ -0,0 +1,17 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eou pipefail
|
||||
|
||||
export NUM_PKGS=${1:-1000}
|
||||
|
||||
# measure date ini milliseconds
|
||||
echo -e "\nBenchmarking ${NUM_PKGS}x builtins.derivaton via pkg-funcs"
|
||||
time nix eval --impure -f ./builtins-derivation-modules-vs-pkg-func.nix --json pkg-funcs > /dev/null
|
||||
|
||||
echo -e "\nBenchmarking ${NUM_PKGS}x builtins.derivaton via modules"
|
||||
time nix eval --impure -f ./builtins-derivation-modules-vs-pkg-func.nix --json modules > /dev/null
|
||||
|
||||
echo -e "\nBenchmarking ${NUM_PKGS}x mkDerivation via pkg-funcs"
|
||||
time nix eval --impure -f ./mkDerivation-modules-vs-pkg-func.nix --json pkg-funcs > /dev/null
|
||||
|
||||
echo -e "\nBenchmarking ${NUM_PKGS}x mkDerivation via modules"
|
||||
time nix eval --impure -f ./mkDerivation-modules-vs-pkg-func.nix --json modules > /dev/null
|
49
misc/benchmarks/builtins-derivation-modules-vs-pkg-func.nix
Normal file
49
misc/benchmarks/builtins-derivation-modules-vs-pkg-func.nix
Normal file
@ -0,0 +1,49 @@
|
||||
{dream2nixSource ? ../..}: let
|
||||
dream2nix = import dream2nixSource;
|
||||
nixpkgs = import dream2nix.inputs.nixpkgs {};
|
||||
lib = nixpkgs.lib;
|
||||
|
||||
_callModule = module:
|
||||
nixpkgs.lib.evalModules {
|
||||
specialArgs.dream2nix = dream2nix;
|
||||
specialArgs.packageSets.nixpkgs = nixpkgs;
|
||||
modules = [module dream2nix.modules.drv-parts.core];
|
||||
};
|
||||
|
||||
# like callPackage for modules
|
||||
callModule = module: (_callModule module).config.public;
|
||||
|
||||
numPkgs = lib.toInt (builtins.getEnv "NUM_PKGS");
|
||||
|
||||
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"];
|
||||
}
|
||||
);
|
||||
|
||||
modules = lib.genAttrs (map toString (lib.range 0 numPkgs)) (
|
||||
num:
|
||||
callModule {
|
||||
imports = [
|
||||
dream2nix.modules.drv-parts.builtins-derivation
|
||||
];
|
||||
name = "hello-${num}";
|
||||
version = "2.12.1";
|
||||
builtins-derivation = {
|
||||
system = "x86_64-linux";
|
||||
builder = "/bin/sh";
|
||||
args = ["sh" "-c" "echo hello-${num} > $out"];
|
||||
};
|
||||
}
|
||||
);
|
||||
in {
|
||||
inherit
|
||||
pkg-funcs
|
||||
modules
|
||||
;
|
||||
}
|
51
misc/benchmarks/mkDerivation-modules-vs-pkg-func.nix
Normal file
51
misc/benchmarks/mkDerivation-modules-vs-pkg-func.nix
Normal file
@ -0,0 +1,51 @@
|
||||
{dream2nixSource ? ../..}: let
|
||||
dream2nix = import dream2nixSource;
|
||||
nixpkgs = import dream2nix.inputs.nixpkgs {};
|
||||
lib = nixpkgs.lib;
|
||||
|
||||
_callModule = module:
|
||||
nixpkgs.lib.evalModules {
|
||||
specialArgs.dream2nix = dream2nix;
|
||||
specialArgs.packageSets.nixpkgs = nixpkgs;
|
||||
modules = [module dream2nix.modules.drv-parts.core];
|
||||
};
|
||||
|
||||
# like callPackage for modules
|
||||
callModule = module: (_callModule module).config.public;
|
||||
|
||||
numPkgs = lib.toInt (builtins.getEnv "NUM_PKGS");
|
||||
|
||||
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;
|
||||
}
|
||||
);
|
||||
|
||||
modules = lib.genAttrs (map toString (lib.range 0 numPkgs)) (num:
|
||||
callModule rec {
|
||||
imports = [
|
||||
dream2nix.modules.drv-parts.mkDerivation
|
||||
];
|
||||
name = "hello-${num}";
|
||||
version = "2.12.1";
|
||||
deps.stdenv = nixpkgs.stdenv;
|
||||
mkDerivation = {
|
||||
src = nixpkgs.fetchurl {
|
||||
url = "mirror://gnu/hello/hello-${version}.tar.gz";
|
||||
sha256 = "sha256-jZkUKv2SV28wsM18tCqNxoCZmLxdYH2Idh9RLibH2yA=";
|
||||
};
|
||||
};
|
||||
});
|
||||
in {
|
||||
inherit
|
||||
pkg-funcs
|
||||
modules
|
||||
;
|
||||
}
|
Loading…
Reference in New Issue
Block a user