linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Perf feature?
@ 2013-03-26 15:22 kernel kernel
  2013-03-26 18:02 ` Vince Weaver
  0 siblings, 1 reply; 3+ messages in thread
From: kernel kernel @ 2013-03-26 15:22 UTC (permalink / raw)
  To: linux-perf-users

Hi,

Is it possible to use perf to record the performance counters of
specific lines of code instead of the entire program?

Best Regards,

Ken

--
Ken O'Brien
PhD Researcher
Simulation Science and Extreme Events Cluster,
3B1, UCD CASL,
8 Belfield Business Park,
Dublin 4,
Ireland.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Perf feature?
  2013-03-26 15:22 Perf feature? kernel kernel
@ 2013-03-26 18:02 ` Vince Weaver
  2013-03-28 18:05   ` kernel kernel
  0 siblings, 1 reply; 3+ messages in thread
From: Vince Weaver @ 2013-03-26 18:02 UTC (permalink / raw)
  To: kernel kernel; +Cc: linux-perf-users

On Tue, 26 Mar 2013, kernel kernel wrote:

> Is it possible to use perf to record the performance counters of
> specific lines of code instead of the entire program?

If you want exact counts (i.e., these three lines of code had exactly 
20 branch misses) you'll need to instrument your code using a library like 
PAPI, or else insert raw perf_event calls yourself before and after 
the lines of interest (see the example at the end of the perf_event_open 
manpage).

Doing self-monitoring like this introduces a certain amount of overhead 
into your program and measurements.

Vince

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Perf feature?
  2013-03-26 18:02 ` Vince Weaver
@ 2013-03-28 18:05   ` kernel kernel
  0 siblings, 0 replies; 3+ messages in thread
From: kernel kernel @ 2013-03-28 18:05 UTC (permalink / raw)
  To: Vince Weaver; +Cc: linux-perf-users

Thanks. I will try out both options.

On Tue, Mar 26, 2013 at 6:02 PM, Vince Weaver <vince@deater.net> wrote:
> On Tue, 26 Mar 2013, kernel kernel wrote:
>
>> Is it possible to use perf to record the performance counters of
>> specific lines of code instead of the entire program?
>
> If you want exact counts (i.e., these three lines of code had exactly
> 20 branch misses) you'll need to instrument your code using a library like
> PAPI, or else insert raw perf_event calls yourself before and after
> the lines of interest (see the example at the end of the perf_event_open
> manpage).
>
> Doing self-monitoring like this introduces a certain amount of overhead
> into your program and measurements.
>
> Vince



-- 
Ken O'Brien
PhD Researcher
Simulation Science and Extreme Events Cluster,
3B1, UCD CASL,
8 Belfield Business Park,
Dublin 4,
Ireland.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-03-28 18:05 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-26 15:22 Perf feature? kernel kernel
2013-03-26 18:02 ` Vince Weaver
2013-03-28 18:05   ` kernel kernel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).