You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Looked at this a bit with @nateberkopec yesterday. The speedscope command itself is written in javascript, so needs a node runtime. But, looking at it more closely, it is mostly creating some temporary html and javascript files that eventually load the bundled dist/release/index.html.
Knowing that, we could port it to another language... for example, bash:
#!/bin/bashset -x
helpString="Usage: speedscope [filepath]If invoked with no arguments, will open a local copy of speedscope in your default browser.Once open, you can browse for a profile to import.If - is used as the filepath, will read from stdin instead.cat /path/to/profile | speedscope - "functiongetProfileBuffer() {
if [ "$1"=="-" ];then
cat -
else
cat $1fi
}
urlToOpen="file://$(realpath "$(dirname $0)/../dist/release/index.html")"
filePrefix="speedscope-$(date +%s)-$$"
tempdir=$(mktemp -d)
jsPath="$tempdir/$filePrefix.js"echo"Creating temp file $jsPath"
jsSource="speedscope.loadFileFromBase64(\"$1\", \"$(getProfileBuffer $1| base64 -w 0)\")"echo"$jsSource">"$jsPath"
urlToOpen="$urlToOpen#localProfilePath=$jsPath"
htmlPath="$tempdir/$filePrefix.html"echo"Creating temp file $htmlPath"
cat <<EOF > "$htmlPath"<script>window.location="${urlToOpen}"</script>EOFfunctionopenBrowser() {
ifcommand -v xdg-open > /dev/null;then
xdg-open $1elifcommand -v open > /dev/null;then
open $1elseecho"Could not open $1 in a browser. Please open it manually."fi
}
urlToOpen="file://${htmlPath}"echo"Opening $urlToOpen in your default browser"
openBrowser $urlToOpen
This still requires the static files for speedscope to be installed somehwere
One way to do this would be to make part of releasing singed:
download the latest speedscope (or a preconfigured version?)
include that in the gem
write a ruby version of the speedscope command to do the same thing the node version does, using bundled speedscope.
Currently, singed assumes you have a working node install, and can run
npx
to be able to install and run speedscope.Is there any way to bundle speedscope to reduce friction even more?
When you run
npx speedscope <path>
, it is essentially creating a static HTML file, and then singed is usingopen
on it to get a browser for it.The text was updated successfully, but these errors were encountered: