Skip to content

Instantly share code, notes, and snippets.

@flokli
Last active May 24, 2023 09:02
Show Gist options
  • Save flokli/0fa74eb334a3c388df0f2cd85f281316 to your computer and use it in GitHub Desktop.
Save flokli/0fa74eb334a3c388df0f2cd85f281316 to your computer and use it in GitHub Desktop.
tvix-cli eval without shelling out to `nix-store --add`
tvix-cli from https://cl.tvl.fyi/c/depot/+/8572/33:
❯ /nix/store/fi3j1sbpd2fzwbjnak924z58zhpd07j0-hyperfine-1.16.1/bin/hyperfine --warmup 10 './target/release/tvix -E "with import <nixpkgs>{}; toString stdenv"' 'nix-instantiate --eval --json --expr "with import <nixpkgs>{}; toString stdenv"'
Benchmark 1: ./target/release/tvix -E "with import <nixpkgs>{}; toString stdenv"
Time (mean ± σ): 1.235 s ± 0.013 s [User: 1.161 s, System: 0.074 s]
Range (min … max): 1.218 s … 1.254 s 10 runs
Benchmark 2: nix-instantiate --eval --json --expr "with import <nixpkgs>{}; toString stdenv"
Time (mean ± σ): 193.7 ms ± 3.4 ms [User: 161.7 ms, System: 32.0 ms]
Range (min … max): 190.3 ms … 203.1 ms 14 runs
Summary
'nix-instantiate --eval --json --expr "with import <nixpkgs>{}; toString stdenv"' ran
6.38 ± 0.13 times faster than './target/release/tvix -E "with import <nixpkgs>{}; toString stdenv"'
❯ /nix/store/fi3j1sbpd2fzwbjnak924z58zhpd07j0-hyperfine-1.16.1/bin/hyperfine --warmup 10 './target/release/tvix -E "with import <nixpkgs>{}; toString hello"' 'nix-instantiate --eval --json --expr "with import <nixpkgs>{}; toString hello"'
Benchmark 1: ./target/release/tvix -E "with import <nixpkgs>{}; toString hello"
Time (mean ± σ): 1.346 s ± 0.020 s [User: 1.264 s, System: 0.082 s]
Range (min … max): 1.317 s … 1.383 s 10 runs
Benchmark 2: nix-instantiate --eval --json --expr "with import <nixpkgs>{}; toString hello"
Time (mean ± σ): 212.2 ms ± 5.8 ms [User: 173.4 ms, System: 31.9 ms]
Range (min … max): 206.5 ms … 223.6 ms 13 runs
Summary
'nix-instantiate --eval --json --expr "with import <nixpkgs>{}; toString hello"' ran
6.35 ± 0.20 times faster than './target/release/tvix -E "with import <nixpkgs>{}; toString hello"'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment