aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/profile_history.sh31
1 files changed, 31 insertions, 0 deletions
diff --git a/scripts/profile_history.sh b/scripts/profile_history.sh
new file mode 100755
index 00000000..94f5c7ed
--- /dev/null
+++ b/scripts/profile_history.sh
@@ -0,0 +1,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