108

Need suggestion on tools similar to kcachegrind wingrind valgrind for mac platform.

I don't think these work on mac, I already checked these.

Manish
  • 133
  • 2
  • 8
indianwebdevil
  • 4,879
  • 7
  • 37
  • 51
  • I am trying to profile php/javascript code, so more interested in those profilers. Thanks anycase for your inputs. – indianwebdevil Dec 17 '10 at 17:59
  • 1
    I think most browsers ship with their own Javascript interpreters, but Safari uses JavascriptCore which is exposed throughout the OS and therefore the thing that almost certain runs scripted Javascript content in other places like Cheetah3D. If you enable the 'Develop' menu in the preferences then there's a javascript profiler in there. – Tommy Dec 18 '10 at 16:45
  • See also: http://stackoverflow.com/questions/5426799/is-there-any-kcachegrind-alternative-for-mac-os-x-outta-there/15952369 – kenorb Apr 11 '13 at 15:09

8 Answers8

149

I ended up using qcachegrind on OSX. It can be installed via brew

brew install qcachegrind

or, to enable graphviz support:

brew install qcachegrind --with-graphviz

What's great about this program is that I successfully loaded a 6.1GB cachegrind file on my MacBook Pro! Pretty slick!

David Riccitelli
  • 7,491
  • 5
  • 42
  • 56
mr-sk
  • 13,174
  • 11
  • 66
  • 101
  • 10
    `brew update` before doing this prevents weird erros :) – grosser Jun 03 '13 at 18:56
  • 3
    `brew install graphviz` if you want some pretty call graphs. – Ngoc Pham May 26 '14 at 00:50
  • 2
    I had to symlink dot to get callgraphs to work sudo ln -s /usr/local/bin/dot /usr/bin/dot – John Kramlich May 27 '14 at 08:27
  • This worked for me without a problem! Thanks! – Răzvan Ciocănel Jan 07 '15 at 13:08
  • 1
    from this, https://blog.josephscott.org/2013/07/03/qcachegrind-kcachegrind-on-mac-os-x/ in comments, to get around system protection to use dot: from @Motrin: This does no longer work in OSX El Capitan due to System Integration Protection: sudo ln -s /usr/local/bin/dot /usr/bin/dot Workaround: $ cd /Applications/qcachegrind.app/Contents/MacOS $ mv qcachegrind qcachegrind.bin $ echo ‘#!/bin/bash export PATH=”$PATH:/usr/local/bin” $(dirname $0)/qcachegrind.bin exit 0’ > qcachegrind $ chmod +x qcachegrind Then start qcachegrind as usual. – troseman Oct 07 '16 at 03:59
  • Re above comment from @Avibodha, make sure you replace the curly quotes with normal ones, and add newlines inside the qcachegrind file. – Matt Gibson Dec 07 '16 at 14:45
  • 5
    The `--with-graphviz` arg would not work for me (even after `brew update` and `brew doctor`), but then doing `brew install qcachegrind` and `brew install graphviz` as separate commands worked. – BoltzmannBrain Feb 02 '17 at 04:02
  • 2
    The Homebrew formula for qcachegrind has a dependency on graphviz, so the following suffices to install this in 2022 `brew install qcachegrind` – Brian Jan 20 '22 at 00:28
67

Try the qcachegrind + Graphviz killer combo.

It installs quickly via brew, which is nice.

Check out these instructions, basically install it via:

brew install qcachegrind

which will download other dependencies such as qtand graphviz.

kenorb
  • 155,785
  • 88
  • 678
  • 743
GlennR
  • 969
  • 8
  • 6
  • 13
    There is now a 'brew install qcachegrind' where the formula is based on that blog. Although it (atm) does not install the /Applications/QCachegrind.app, just a qcachegrind binary. – Derek Downey Jul 06 '12 at 20:25
  • Another useful post: http://blog.jcmultimedia.com.au/2014/03/profiling-php-on-osx-with-xdebug-kcachegrind/ – Jazzo Sep 25 '14 at 07:03
23

You can install KCacheGrind using MacPorts.

There are also some alternatives like:

See also: Is there any KCacheGrind alternative for Mac Os X outta there?

ᴍᴇʜᴏᴠ
  • 4,804
  • 4
  • 44
  • 57
kenorb
  • 155,785
  • 88
  • 678
  • 743
  • 1
    for those who use phpStorm: it has a good built-in XDebug profile viewer (better experience than qcachegrind) – kalabro Feb 26 '22 at 13:29
16

Both valgrind and kcachegrind are available for Mac OS X.

You can install them using MacPorts:

sudo port install valgrind kcachegrind
raimue
  • 4,322
  • 1
  • 21
  • 31
  • i tried installing macports and did sudo port install valgrind kcachegrind, This was the error for both apps ------------------- Warning: No index(es) found! Have you synced your source indexes? Error: Port kcachegrind not found---------------- any clue whats going on – indianwebdevil Dec 27 '10 at 08:10
  • 1
    The kcachegrind port was formally abandoned 2 years ago :( https://trac.macports.org/log/trunk/dports/devel/kcachegrind/Portfile – Potatoswatter Oct 11 '12 at 00:56
  • @Potatoswatter There are many ports in MacPorts that do not have a specific maintainer. This does imply that the port cannot be installed anymore. – raimue Oct 19 '12 at 14:38
  • 2
    @Raim It does imply that the port now installs software 2 years out of date. – Potatoswatter Oct 21 '12 at 13:49
8

Webgrind runs in PHP and can read the cachegrind output of XDebug. It currently doesn't offer all the functionality of KCacheGrind, but it is super simple to install, and seems to have renewed activity.

Jan Fabry
  • 7,221
  • 2
  • 36
  • 41
7

MacCallGrind is a semi-commercial alternative available for the Mac. I've experimented with the free version which is limited to 3MB grind files. It's roughly equivalent to WinCacheGrind in terms of functionality.

nurikabe
  • 3,802
  • 2
  • 31
  • 39
2

Apple supply Instruments for monitoring runtime allocation of stuff and finding leaks, Shark for explicit profiling and Guard Malloc (directly built into Xcode) for memory allocation debugging. These all come as part of the developer tools.

Tommy
  • 99,986
  • 12
  • 185
  • 204
1

valgrind is available for the mac. If you are building a cocoa app, you can use the tools that come with XCode such as leaks, they are very good.

shreyasva
  • 13,126
  • 25
  • 78
  • 101