2. Getting started with OProfile using ocount

ocount is an OProfile tool that can be used to count native hardware events occurring in either a specific application, a set of processes or threads, a set of active system processors, or the entire system. The data collected during a counting session is displayed to stdout by default, but may also be saved to a file. The ocount syntax is as follows:

ocount [ options ] [ --system-wide | --process-list <pids> | --thread-list <tids> | --cpu-list <cpus> [ command [ args ] ] ]

A typical usage might look like this:

ocount --events=CPU_CLK_UNHALTED,INST_RETIRED /home/user1/my_test_program my_arg

When my_test_program completes (or when you press Ctrl-C), counting stops and the results are displayed to the screen (as shown below).

Events were actively counted for 2.8 seconds.
Event counts (actual) for /home/user1/my_test_program:
	Event                   Count                    % time counted
	CPU_CLK_UNHALTED        9,408,018,070            100.00
	INST_RETIRED            16,719,918,108           100.00