2023-09-15 00:33:46 +02:00
|
|
|
#!/bin/zsh
|
|
|
|
|
|
|
|
function start_tracing {
|
|
|
|
zmodload zsh/zprof
|
|
|
|
zmodload zsh/datetime
|
2024-04-05 15:10:01 +02:00
|
|
|
|
2023-09-15 00:33:46 +02:00
|
|
|
setopt PROMPT_SUBST
|
|
|
|
PS4+='+$EPOCHREALTIME %N:%i> '
|
2024-04-05 15:10:01 +02:00
|
|
|
logfile=$(mktemp --tmpdir zsh_profile.XXXXXXXX)
|
2023-09-15 00:33:46 +02:00
|
|
|
echo "logging to $logfile"
|
|
|
|
exec 3>&2 2>$logfile
|
|
|
|
setopt XTRACE
|
|
|
|
}
|
|
|
|
|
|
|
|
function stop_tracing {
|
|
|
|
unsetopt XTRACE
|
|
|
|
exec 2>&3 3>&-
|
2024-04-05 15:10:01 +02:00
|
|
|
zprof | tee zprof_out.log | vim -c "set buftype=nofile" -
|
|
|
|
|
|
|
|
zmodload -u zsh/zprof
|
|
|
|
zmodload -u zsh/datetime
|
2023-09-15 00:33:46 +02:00
|
|
|
}
|