{"id":13493009,"url":"https://github.com/uber-archive/go-torch","last_synced_at":"2025-09-27T07:32:30.466Z","repository":{"id":35214624,"uuid":"39473685","full_name":"uber-archive/go-torch","owner":"uber-archive","description":"Stochastic flame graph profiler for Go programs","archived":true,"fork":false,"pushed_at":"2018-11-07T07:13:54.000Z","size":327,"stargazers_count":3958,"open_issues_count":10,"forks_count":244,"subscribers_count":2078,"default_branch":"master","last_synced_at":"2024-04-15T07:14:39.807Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/uber-archive.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-07-21T22:49:42.000Z","updated_at":"2024-03-30T04:11:46.000Z","dependencies_parsed_at":"2022-08-04T00:30:15.470Z","dependency_job_id":null,"html_url":"https://github.com/uber-archive/go-torch","commit_stats":null,"previous_names":["uber/go-torch"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uber-archive%2Fgo-torch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uber-archive%2Fgo-torch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uber-archive%2Fgo-torch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uber-archive%2Fgo-torch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/uber-archive","download_url":"https://codeload.github.com/uber-archive/go-torch/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234410401,"owners_count":18828196,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T19:01:11.299Z","updated_at":"2025-09-27T07:32:21.810Z","avatar_url":"https://github.com/uber-archive.png","language":"Go","funding_links":[],"categories":["Misc","Go"],"sub_categories":[],"readme":"# go-torch [![Build Status](https://travis-ci.org/uber/go-torch.svg?branch=master)](https://travis-ci.org/uber/go-torch) [![Coverage Status](http://coveralls.io/repos/uber/go-torch/badge.svg?branch=master\u0026service=github)](http://coveralls.io/github/uber/go-torch?branch=master) [![GoDoc](https://godoc.org/github.com/uber/go-torch?status.svg)](https://godoc.org/github.com/uber/go-torch)\n\n## go-torch is deprecated, use pprof instead\n\nAs of Go 1.11, flamegraph visualizations are available in `go tool pprof` directly!\n\n```\n# This will listen on :8081 and open a browser.\n# Change :8081 to a port of your choice.\n$ go tool pprof -http=\":8081\" [binary] [profile]\n```\n\nIf you cannot use Go 1.11, you can get the latest `pprof` tool and use it instead:\n\n```\n# Get the pprof tool directly\n$ go get -u github.com/google/pprof\n\n$ pprof -http=\":8081\" [binary] [profile]\n```\n\n## Synopsis\n\nTool for stochastically profiling Go programs. Collects stack traces and\nsynthesizes them into a flame graph. Uses Go's built in [pprof][] library.\n\n[pprof]: https://golang.org/pkg/net/http/pprof/\n\n## Example Flame Graph\n\n[![Inception](http://uber.github.io/go-torch/meta.svg)](http://uber.github.io/go-torch/meta.svg)\n\n## Basic Usage\n\n```\n$ go-torch -h\nUsage:\n  go-torch [options] [binary] \u003cprofile source\u003e\n\npprof Options:\n  -u, --url=         Base URL of your Go program (default: http://localhost:8080)\n  -s, --suffix=      URL path of pprof profile (default: /debug/pprof/profile)\n  -b, --binaryinput= File path of previously saved binary profile. (binary profile is anything accepted by https://golang.org/cmd/pprof)\n      --binaryname=  File path of the binary that the binaryinput is for, used for pprof inputs\n  -t, --seconds=     Number of seconds to profile for (default: 30)\n      --pprofArgs=   Extra arguments for pprof\n\nOutput Options:\n  -f, --file=        Output file name (must be .svg) (default: torch.svg)\n  -p, --print        Print the generated svg to stdout instead of writing to file\n  -r, --raw          Print the raw call graph output to stdout instead of creating a flame graph; use with Brendan Gregg's flame graph perl script (see https://github.com/brendangregg/FlameGraph)\n      --title=       Graph title to display in the output file (default: Flame Graph)\n      --width=       Generated graph width (default: 1200)\n      --hash         Colors are keyed by function name hash\n      --colors=      Set color palette. Valid choices are: hot (default), mem, io, wakeup, chain, java,\n                     js, perl, red, green, blue, aqua, yellow, purple, orange\n      --hash         Graph colors are keyed by function name hash\n      --cp           Graph use consistent palette (palette.map)\n      --inverted     Icicle graph\nHelp Options:\n  -h, --help         Show this help message\n```\n\n### Write flamegraph using /debug/pprof endpoint\n\nThe default options will hit `http://localhost:8080/debug/pprof/profile` for\na 30 second CPU profile, and write it out to torch.svg\n\n```\n$ go-torch\nINFO[19:10:58] Run pprof command: go tool pprof -raw -seconds 30 http://localhost:8080/debug/pprof/profile\nINFO[19:11:03] Writing svg to torch.svg\n```\n\nYou can customize the base URL by using `-u`\n\n```\n$ go-torch -u http://my-service:8080/\nINFO[19:10:58] Run pprof command: go tool pprof -raw -seconds 30 http://my-service:8080/debug/pprof/profile\nINFO[19:11:03] Writing svg to torch.svg\n```\n\nOr change the number of seconds to profile using `--seconds`:\n\n```\n$ go-torch --seconds 5\nINFO[19:10:58] Run pprof command: go tool pprof -raw -seconds 5 http://localhost:8080/debug/pprof/profile\nINFO[19:11:03] Writing svg to torch.svg\n```\n\n\n### Using pprof arguments\n\n`go-torch` will pass through arguments to `go tool pprof`, which lets you take\nexisting pprof commands and easily make them work with `go-torch`.\n\nFor example, after creating a CPU profile from a benchmark:\n```\n$ go test -bench . -cpuprofile=cpu.prof\n\n# This creates a cpu.prof file, and the $PKG.test binary.\n```\n\nThe same arguments that can be used with `go tool pprof` will also work\nwith `go-torch`:\n```\n$ go tool pprof main.test cpu.prof\n\n# Same arguments work with go-torch\n$ go-torch main.test cpu.prof\nINFO[19:00:29] Run pprof command: go tool pprof -raw -seconds 30 main.test cpu.prof\nINFO[19:00:29] Writing svg to torch.svg\n```\n\n\nFlags that are not handled by `go-torch` are passed through as well:\n```\n$ go-torch --alloc_objects main.test mem.prof\nINFO[19:00:29] Run pprof command: go tool pprof -raw -seconds 30 --alloc_objects main.test mem.prof\nINFO[19:00:29] Writing svg to torch.svg\n```\n\n## Integrating With Your Application\n\nTo add profiling endpoints in your application, follow the official\nGo docs [here][].\nIf your application is already running a server on the DefaultServeMux,\njust add this import to your application.\n\n[here]: https://golang.org/pkg/net/http/pprof/\n\n```go\nimport _ \"net/http/pprof\"\n```\n\nIf your application is not using the DefaultServeMux, you can still easily\nexpose pprof endpoints by manually registering the net/http/pprof handlers or by\nusing a library like [this one](https://github.com/e-dard/netbug).\n\n## Installation\n\n```\n$ go get github.com/uber/go-torch\n```\n\nYou can also use go-torch using docker:\n```\n$ docker run uber/go-torch -u http://[address-of-host] -p \u003e torch.svg\n```\n\nUsing `-p` will print the SVG to standard out, which can then be redirected\nto a file. This avoids mounting volumes to a container.\n\n### Get the flame graph script:\n\nWhen using the `go-torch` binary locally, you will need the Flamegraph scripts\nin your `PATH`:\n\n```\n$ cd $GOPATH/src/github.com/uber/go-torch\n$ git clone https://github.com/brendangregg/FlameGraph.git\n```\n\n## Development and Testing\n\n### Install the Go dependencies:\n\n```\n$ go get github.com/Masterminds/glide\n$ cd $GOPATH/src/github.com/uber/go-torch\n$ glide install\n```\n\n### Run the Tests\n\n```\n$ go test ./...\nok    github.com/uber/go-torch   0.012s\nok    github.com/uber/go-torch/graph   0.017s\nok    github.com/uber/go-torch/visualization 0.052s\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fuber-archive%2Fgo-torch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fuber-archive%2Fgo-torch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fuber-archive%2Fgo-torch/lists"}