gperftools_d ~master

D bindings for gperftools


To use this package, run the following command in your project's root directory:

gperftools_d

D bindings for gperftools(Google Performance Tools)

<a href="https://code.dlang.org/packages/gperftoolsd" title="Go to gperftoolsd"><img src="https://img.shields.io/dub/v/gperftoolsd.svg" alt="Dub version"></a> <a href="https://code.dlang.org/packages/gperftoolsd" title="Go to gperftoolsd"><img src="https://img.shields.io/dub/dt/gperftoolsd.svg" alt="Dub downloads"></a>

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

Authors:
  • Prasun Anand
Dependencies:
none
Versions:
0.1.0 2017-Mar-29
~master 2017-Apr-01
Show all 2 versions
Download Stats:
  • 0 downloads today

  • 0 downloads this week

  • 0 downloads this month

  • 135 downloads total

Score:
0.7
Short URL:
gperftools_d.dub.pm