Created
May 10, 2016 08:57
-
-
Save lukego/646b5e47a6de19c7ac0550bfb4ecf12c to your computer and use it in GitHub Desktop.
nix benchmarking script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ code ? "unknown" | |
, src ? (builtins.fetchTarball https://github.com/snabbco/snabb/tarball/next) | |
, runs ? 20 | |
, pkgs ? (import <nixpkgs> {})}: | |
with pkgs; | |
with lib; | |
let | |
# nTimes: repeat building a derivation for n times | |
# nTimes: Derivation -> Int -> [Derivation] | |
nTimes = drv: n: map (i: overrideDerivation drv (attrs: { name = "snabb-" + code + "-" + drv.benchName + "-num-${toString i}"; run = i; })) (range 1 n); | |
# runs the benchmark without chroot to be able to use pci device assigning | |
mkBenchmarks = { name, snabb, command, times ? runs }: | |
nTimes (runCommand "benchmark-${snabb.name}" { benchName = name; requiredSystemFeatures = "performance"; __noChroot = true; } '' | |
mkdir -p $out/nix-support | |
echo "Running benchmark $run at $(date)" | |
/var/setuid-wrappers/sudo SNABB_PCI0=0000:01:00.0 SNABB_PCI1=0000:01:00.1 SNABB_SHM_ROOT=state \ | |
${command snabb} 2>&1 | tee $out/log.txt | |
# Save shared memory object state for post-moretem analysis | |
[ -d state ] && /var/setuid-wrappers/sudo chown -R $(whoami) state | |
[ -d state ] && tar czf $out/state.tar.gz state | |
echo "file log $out/log.txt" >> $out/nix-support/hydra-build-products | |
echo "file tarball $out/state.tar.gz" >> $out/nix-support/hydra-build-products | |
'') times; | |
snabb = snabbswitch.overrideDerivation (super: { src = src; enableParallelBuilding = true; }); | |
commandBasic1 = snabb: "${snabb}/bin/snabb snabbmark basic1 100e6"; | |
basic1 = (mkBenchmarks { name = "basic1"; inherit snabb; command = commandBasic1;}); | |
commandIperf1500 = snabb: "bash -c 'cd ${snabb}/src && program/snabbnfv/selftest.sh bench'"; | |
iperf1500 = (mkBenchmarks { name = "iperf1500"; inherit snabb; command = commandIperf1500;}); | |
in { | |
inherit basic1; | |
inherit iperf1500; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment