aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/profile_history.sh
blob: 94f5c7ed5c86bd7f904c657b470819a66c7f217f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#! /usr/bin/env sh

profile() {
    cargo flamegraph --bin atuin --profile profiling -- "$@" 2>/dev/null
}

# SPDX-SnippetBegin
# SPDX-SnippetCopyrightText: 2023 mentalisttraceur (https://github.com/mentalisttraceur)
# Source: https://github.com/atuinsh/atuin/issues/1188#issuecomment-1698354107
run_and_record_in_turtle() {
    id="$(atuin history start --author "benchmark-script" --intent "to-profile atuin itself" -- "$@")"

    "$@"
    status="$?"

    profile history end --exit "$status" "$id"

    return $status
}
# SPDX-SnippetEnd

if [ "$#" -eq 0 ]; then
    echo "Not enough args"
    exit 2
fi

cargo build --profile profiling

run_and_record_in_turtle "$@"

# vim: ft=sh