Git Product home page Git Product logo

dmdprof's Introduction

dmdprof

This is a DMD compilation time profiler. It allows profiling and visualizing which parts of the D code take up most of the time compiling.

Example

Click image above for working tooltips and hyperlinks.

Example taken from here.

Usage

  1. Build a debug DMD, e.g. using make -f posix.mak BUILD=debug in dmd/src.

  2. Run the debug DMD you built under GDB, and pass the program to compile and profile:

    $ gdb --args .../dmd/generated/linux/debug/64/dmd -o- your_program.d
    

    If you use a build tool like rdmd or Dub, you need to first find the dmd invocation it uses, then use that. Try enabling verbose output.

  3. Load the dmdprof.py GDB script from this repository:

    (gdb) source path/to/dmdprof.py
    
  4. Run the profiler:

    (gdb) python DMDProfiler().profile()
    

    You can optionally specify a sampling interval:

    (gdb) python DMDProfiler(0.001).profile()
    

    The sampling interval specifies the duration (in seconds) between samples taken. The default is 0.01, and the lowest possible value is 0, meaning to take samples as quickly as possible.

    Note that currently GDB leaks about 15-30 MB of memory per sample (!), so watch your memory usage to avoid crashing your machine.

    The profiler will save the results to a profile.json file.

  5. Use gprof2dot to generate a GraphViz .dot file, pipe it through the linkify program in this repository, and pipe the result into dot:

    ./gprof2dot.py -f json path/to/profile.json --root=-2:-2 -n 2 -e 0 | rdmd path/to/linkify.d | dot -Tsvg > profile.svg
    

    Adjust gprof2dot -n parameter to taste.

    To generate correct, permanent links in the output file, you can specify Phobos and Druntime versions as Git commit SHA1s or tag names using the --phobos and --druntime arguments to linkify.

dmdprof's People

Contributors

cybershadow avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.