linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Ahern <dsahern@gmail.com>
To: Benjamin Moody <benjamin.moody@gmail.com>,
	linux-perf-users@vger.kernel.org
Subject: Re: Bizarre results from perf event API
Date: Fri, 20 Feb 2015 17:39:15 -0700	[thread overview]
Message-ID: <54E7D3B3.7020108@gmail.com> (raw)
In-Reply-To: <CAAk6P0UvfKGhaFJKKdRkVcZbx+XNoJLGgKtw3f-hVuNfGSjNDQ@mail.gmail.com>

On 2/20/15 4:26 PM, Benjamin Moody wrote:
> I'm trying to write a program that uses the Linux perf event API to
> track the CPU usage of an arbitrary task.  I'm following the
> documentation at <http://linux.die.net/man/2/perf_event_open>.
>
> My program (highly simplified version shown below) seems to work most
> of the time, and as far as I can tell, it should be measuring exactly
> the same thing as what 'perf stat -e instructions:uD' measures.
> However, when I try measuring the performance of a certain large
> proprietary application, I get *completely* different results from my
> program and from perf stat.  (The results from perf are somewhat
> believable; mine are not.)
>

Trying using a program with established results. e.g., This is from 
PeterZ years ago. On intel 'perf stat -e instructions a.out' should show 
~1 billion (a wee bit more, but clearly in the 1b range).

int main (void)
{
         int i;

         for (i = 0; i < 100000000; i++) {
                 asm("nop");
                 asm("nop");
                 asm("nop");
                 asm("nop");
                 asm("nop");
                 asm("nop");
                 asm("nop");
         }

         return 0;
}

  reply	other threads:[~2015-02-21  0:39 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-20 23:26 Bizarre results from perf event API Benjamin Moody
2015-02-21  0:39 ` David Ahern [this message]
2015-02-21 21:44   ` Benjamin Moody
2015-02-21 22:59     ` Vince Weaver
2015-02-22 20:12       ` Benjamin Moody
2015-02-22 20:37         ` Vince Weaver
2015-02-24  0:46           ` Benjamin Moody
2015-02-24  1:21     ` David Ahern
2015-02-27 21:41       ` Benjamin Moody
2015-02-23 20:44 ` Andi Kleen
2015-02-23 23:13   ` Benjamin Moody

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=54E7D3B3.7020108@gmail.com \
    --to=dsahern@gmail.com \
    --cc=benjamin.moody@gmail.com \
    --cc=linux-perf-users@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).