run-benchmarks.sh: Use python3 oneliner instead of jq

I am setting up a new computer and thus are missing a lot of tools. I
noticed we rely on `jq` being installed, which is a bit annoying when it
is not installed yet.

We can quite easily get rid of this dependecy on `jq` by using a simple
`python3` oneliner.
This commit is contained in:
Martin Nordholts 2022-02-02 21:02:31 +01:00
parent a565662cf3
commit 0fa99518ce

View File

@ -9,15 +9,15 @@ if ! command -v hyperfine > /dev/null 2>&1; then
exit 1
fi
# Check that jq is installed.
if ! command -v jq > /dev/null 2>&1; then
echo "'jq' does not seem to be installed."
echo "You can get it here: https://stedolan.github.io/jq"
# Check that python3 is installed.
if ! command -v python3 > /dev/null 2>&1; then
echo "'python3' does not seem to be installed."
echo "You can get it here: https://www.python.org/downloads/"
exit 1
fi
get_cargo_target_dir() {
cargo metadata --no-deps --format-version 1 | jq -r .target_directory
cargo metadata --no-deps --format-version 1 | python3 -c 'import sys, json; print(json.load(sys.stdin)["target_directory"])'
}
heading() {