Comments (1)
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/bash
set -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 -
"
function getProfileBuffer() {
if [ "$1" == "-" ]; then
cat -
else
cat $1
fi
}
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>
EOF
function openBrowser() {
if command -v xdg-open > /dev/null; then
xdg-open $1
elif command -v open > /dev/null; then
open $1
else
echo "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.
from singed.
Related Issues (11)
- Add `start` and `stop` methods for when code isn't conveniently block wrappable HOT 4
- Received NoMethodError: undefined method `print_json' HOT 1
- Add License to gemspec
- Automate releasing HOT 2
- Support vernier
- Running in project with rspec HOT 4
- Sidekiq middleware
- rbspy doesn't support Ruby 3.3.2 yet
- Need to create folder tmp/speedscope before using CLI HOT 1
- `label` cannot be provided as a keyword HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from singed.