<commit_before># go-torch [![Build Status](https://travis-ci.org/uber/go-torch.svg?branch=master)](https://travis-ci.org/uber/go-torch) [![GoDoc](https://godoc.org/github.com/uber/go-torch?status.svg)](https://godoc.org/github.com/uber/go-torch)

## Synopsis

Tool for stochastically profiling Go programs. Collects stack traces and
synthesizes them into into a flame graph. Uses Go's built in pprof library.

## Example Flame Graph

![Inception](http://uber.github.io/go-torch/meta.svg)

## Basic Usage

```
$ go-torch --help

NAME:
   go-torch - go-torch collects stack traces of a Go application and synthesizes them into into a [flame graph](http://www.brendangregg.com/FlameGraphs/cpuflamegraphs.html)

USAGE:
   go-torch [global options] command [command options] [arguments...]

COMMANDS:
   help, h  Shows a list of commands or help for one command

GLOBAL OPTIONS:
   --url, -u "http://localhost:8080"   base url of your Go program
   --suffix, -s "/debug/pprof/profile" url path of pprof profile
   --binaryinput, -b          file path of raw binary profile; alternative to having go-torch query pprof endpoint (binary profile is anything accepted by https://golang.org/cmd/pprof)
   --time, -t "30"         time in seconds to profile for
   --file, -f "torch.svg"     ouput file name (must be .svg)
   --print, -p          print the generated svg to stdout instead of writing to file
   --raw, -r            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)
   --help, -h           show help
   --version, -v        print the version

```

### File Example

```
$ go-torch --time=15 --file "torch.svg" --url http://localhost:8080
INFO[0000] Profiling ...
INFO[0015] flame graph has been created as torch.svg
```

### Stdout Example

```
$ go-torch --time=15 --print --url http://localhost:8080
INFO[0000] Profiling ...
<svg>
...
</svg>
INFO[0015] flame graph has been printed to stdout
```

### Raw Example

```
$ go-torch --time=15 --raw --url http://localhost:8080
INFO[0000] Profiling ...
function1;function2 3
...
INFO[0015] raw call graph output been printed to stdout
```

## Installation

```
$ go get github.com/uber/go-torch
```

### Install the Go dependencies:

```
$ go get github.com/tools/godep
$ godep restore
```

### Get the flame graph script:

```
$ git clone https://github.com/brendangregg/FlameGraph.git
```
<commit_msg>Update README with documentation for binaryname<commit_after># go-torch [![Build Status](https://travis-ci.org/uber/go-torch.svg?branch=master)](https://travis-ci.org/uber/go-torch) [![GoDoc](https://godoc.org/github.com/uber/go-torch?status.svg)](https://godoc.org/github.com/uber/go-torch)

## Synopsis

Tool for stochastically profiling Go programs. Collects stack traces and
synthesizes them into into a flame graph. Uses Go's built in pprof library.

## Example Flame Graph

![Inception](http://uber.github.io/go-torch/meta.svg)

## Basic Usage

```
$ go-torch --help

NAME:
   go-torch - go-torch collects stack traces of a Go application and synthesizes them into into a [flame graph](http://www.brendangregg.com/FlameGraphs/cpuflamegraphs.html)

USAGE:
   go-torch [global options] command [command options] [arguments...]

COMMANDS:
   help, h  Shows a list of commands or help for one command

GLOBAL OPTIONS:
   --url, -u "http://localhost:8080"   base url of your Go program
   --suffix, -s "/debug/pprof/profile" url path of pprof profile
   --binaryinput, -b          file path of raw binary profile; alternative to having go-torch query pprof endpoint (binary profile is anything accepted by https://golang.org/cmd/pprof)
   --binaryname               file path of the binary that the binaryinput is for, used for pprof inputs
   --time, -t "30"         time in seconds to profile for
   --file, -f "torch.svg"     ouput file name (must be .svg)
   --print, -p          print the generated svg to stdout instead of writing to file
   --raw, -r            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)
   --help, -h           show help
   --version, -v        print the version

```

### File Example

```
$ go-torch --time=15 --file "torch.svg" --url http://localhost:8080
INFO[0000] Profiling ...
INFO[0015] flame graph has been created as torch.svg
```

### Stdout Example

```
$ go-torch --time=15 --print --url http://localhost:8080
INFO[0000] Profiling ...
<svg>
...
</svg>
INFO[0015] flame graph has been printed to stdout
```

### Raw Example

```
$ go-torch --time=15 --raw --url http://localhost:8080
INFO[0000] Profiling ...
function1;function2 3
...
INFO[0015] raw call graph output been printed to stdout
```

### Local pprof Example

```
$ go test -cpuprofile=cpu.pprof
# This creates a cpu.pprof file, and the golang.test binary.
$ go-torch --binaryfile cpu.pprof --binaryname golang.test
INFO[0000] Profiling ...
INFO[0000] flame graph has been created as torch.svg
```

## Installation

```
$ go get github.com/uber/go-torch
```

### Install the Go dependencies:

```
$ go get github.com/tools/godep
$ godep restore
```

### Get the flame graph script:

```
$ git clone https://github.com/brendangregg/FlameGraph.git
```

{'fraction_non_alphanumeric': 0.13752565777197237, 'fraction_numerical': 0.020526217577906326, 'mean_word_length': 3.257347100873709, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 14, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7090814', 'n_tokens_mistral': 1829, 'n_tokens_neox': 1720, 'n_words': 572}