Skip to content

Commit 21081de

Browse files
committed
move ENV var export from buildkite script into buildkite configuration
1 parent 4e2d11a commit 21081de

File tree

3 files changed

+22
-13
lines changed

3 files changed

+22
-13
lines changed

.buildkite/benchmark.sh

+2-11
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,11 @@
33

44
set -euo pipefail
55

6-
netname="${1-}"
7-
8-
if [ -z "$netname" ]; then
9-
echo "usage: benchmark.sh NETWORK"
10-
exit 1
11-
fi
12-
136
echo "--- Build code and benchmarks"
147
stack build --bench --no-run-benchmarks
158

16-
export NETWORK=$netname
17-
18-
echo "+++ Run benchmarks"
19-
stack bench cardano-wallet:restore --interleaved-output --ba "$netname +RTS -N2 -qg -A1m -I0 -T -M8G -h -RTS"
9+
echo "+++ Run benchmarks - $NETWORK"
10+
stack bench cardano-wallet:restore --interleaved-output --ba "$NETWORK +RTS -N2 -qg -A1m -I0 -T -M8G -h -RTS"
2011

2112
hp2pretty restore.hp
2213

.buildkite/nightly.yml

+6-2
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,16 @@ env:
22
NIX_PATH: "channel:nixos-19.03"
33
steps:
44
- label: 'Restore benchmark - testnet'
5-
command: "./.buildkite/benchmark.sh testnet"
5+
command: "./.buildkite/benchmark.sh"
66
timeout_in_minutes: 60
77
agents:
88
system: x86_64-linux
9+
env:
10+
NETWORK: testnet
911
- label: 'Restore benchmark - mainnet'
10-
command: "./.buildkite/benchmark.sh mainnet"
12+
command: "./.buildkite/benchmark.sh"
1113
timeout_in_minutes: 60
1214
agents:
1315
system: x86_64-linux
16+
env:
17+
NETWORK: mainnet

test/bench/Main.hs

+14
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ import Fmt
6161
( fmt, (+|), (+||), (|+), (||+) )
6262
import Say
6363
( sayErr )
64+
import System.Environment
65+
( getArgs, setEnv )
6466
import System.IO
6567
( BufferMode (..), hSetBuffering, stderr, stdout )
6668

@@ -77,6 +79,7 @@ main = do
7779
hSetBuffering stdout NoBuffering
7880
hSetBuffering stderr NoBuffering
7981
installSignalHandlers
82+
getArgs >>= overrideEnvironment
8083
prepareNode
8184
runBenchmarks
8285
[ bench ("restore " <> toText network <> " seq")
@@ -125,6 +128,17 @@ bench benchName action = do
125128
printResult :: Text -> Double -> IO ()
126129
printResult benchName dur = sayErr . fmt $ " "+|benchName|+": "+|secs dur|+""
127130

131+
-- FIXME This only exists because somehow, in buildkite, we can't pass ENV var
132+
-- to the haskell executable? There's probably some Nix magic going on and I
133+
-- don't have time for this.
134+
overrideEnvironment :: [String] -> IO ()
135+
overrideEnvironment [ntwrk] =
136+
setEnv "NETWORK" ntwrk
137+
overrideEnvironment [] =
138+
return ()
139+
overrideEnvironment _ =
140+
fail "benchmark expects only one argument to override the '$NETWORK' ENV var"
141+
128142
{-------------------------------------------------------------------------------
129143
Benchmarks
130144
-------------------------------------------------------------------------------}

0 commit comments

Comments
 (0)