Alternatives to gprof [closed]

gprof (read the paper) exists for historical reasons. If you think it will help you find performance problems, it was never advertised as such. Here’s what the paper says: The profile can be used to compare and assess the costs of various implementations. It does not say it can be used to identify the various … Read more

Measuring execution time of a function in C++

It is a very easy-to-use method in C++11. You have to use std::chrono::high_resolution_clock from <chrono> header. Use it like so: #include <chrono> /* Only needed for the sake of this example. */ #include <iostream> #include <thread> void long_operation() { /* Simulating a long, heavy operation. */ using namespace std::chrono_literals; std::this_thread::sleep_for(150ms); } int main() { using … Read more

How do I analyze a .hprof file?

If you want a fairly advanced tool to do some serious poking around, look at the Memory Analyzer project at Eclipse, contributed to them by SAP. Some of what you can do is mind-blowingly good for finding memory leaks etc — including running a form of limited SQL (OQL) against the in-memory objects, i.e. SELECT … Read more

Simplest way to profile a PHP script

You want xdebug I think. Install it on the server, turn it on, pump the output through kcachegrind (for linux) or wincachegrind (for windows) and it’ll show you a few pretty charts that detail the exact timings, counts and memory usage (but you’ll need another extension for that). It rocks, seriously 😀

How do I profile memory usage in Python?

Python 3.4 includes a new module: tracemalloc. It provides detailed statistics about which code is allocating the most memory. Here’s an example that displays the top three lines allocating memory. from collections import Counter import linecache import os import tracemalloc def display_top(snapshot, key_type=”lineno”, limit=3): snapshot = snapshot.filter_traces(( tracemalloc.Filter(False, “<frozen importlib._bootstrap>”), tracemalloc.Filter(False, “<unknown>”), )) top_stats = … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)