Google Performance Tools for D
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
examples
source/gperftools_d
.gitignore
LICENSE
README.md
dub.json

README.md

gperftools_d

D bindings for gperftools(Google Performance Tools)

Dub version Dub downloads

Installation

Install google-perftools and graphviz

sudo apt-get install google-perftools libgoogle-perftools-dev graphviz

Install go and then install google-pprof.

go get github.com/google/pprof

Performance Profiling

Add gperftools_d in dub.json as a dependency.

  "dependencies": {
    "gperftools_d": "~>0.1.0"
  }

Place the code you want to profile within ProfilerStart() and ProfilerStop().

Example: In the examples/source/app.d file:

import std.stdio;
import gperftools_d.profiler;

int fib(int x) {
  if(x == 0){
    return 0;
  }
  else if(x == 1){
    return 1;
  }
  else{
    return (fib(x-1) + fib(x-2));
  }
}

void main() {
  ProfilerStart();         // Profiling Starts
  foreach (i; 0 .. 30) {
    writeln(fib(i));
  }
  ProfilerStop();          // Profiling Stops
}

To profile:

dub --compiler=ldc2
CPUPROFILE=/tmp/prof.out <path/to/binary> [binary args]
pprof <path/to/binary> /tmp/prof.out      # -pg-like text output
pprof --gv <path/to/binary> /tmp/prof.out # really cool graphical output
pprof --pdf <path/to/binary> /tmp/prof.out > profile.pdf # dump graphical output in profile.pdf

Example output:

Profile.pdf

LICENSE

This software is distributed under the BSD 3-Clause License.

Copyright © 2017, Prasun Anand