mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "kernel coder" <lhrkernelcoder@gmail.com>
To: linux-kernel@vger.kernel.org
Subject: bechmarking kernel code
Date: Thu, 3 May 2007 04:02:49 -0700	[thread overview]
Message-ID: <f69849430705030402v5e737de4sc6ab246a1c64ec0e@mail.gmail.com> (raw)

hi,
     I'm profiling some part of kernel code.Mine profiling mechanism
is based on rdtsc instruction.

Please tell me if i'm profiling correctly.I'm teting linux kernel
2.6.15 and mine system is P4.


function(){

	unsigned long long c1,c2,c3,c4,c5;
	before=readtsc();
	before=readtsc();
	before=readtsc();
	overhead=readtsc()-before;
	c1=testfunc();
	c2=testfunc();
	c3=testfunc();
	c4=testfunc();
	c5=testfunc();

printk(" \n *c1 = %llu c2= %llu c3 = %llu c4 = %llu c5 = %llu overhead
=%llu",cycles1,cycles2,cycles3,cycles4,cycles5,overhead);


}

/***************************************/


unsigned long long readtsc(){
	unsigned long res[2]={0,0};
      __asm__ __volatile__  (
	      "rdtsc\n"
	       : "=a" (res[0]), "=d" (res[1]) );

	return *((unsigned long long *)res);

}

/*******************************************/

unsigned long long testfunc(){
	unsigned long start_cycles[2]={0,0};
	unsigned long end_cycles[2]={0,0};
	unsigned long long total_cycles=0;
	int i;
      __asm__ __volatile__  (               // read TSC, store edx:eax in res
	      "rdtsc\n"
	       : "=a" (start_cycles[0]), "=d" (start_cycles[1]) );


               /*  CODE TO BE PROFILED */


      __asm__ __volatile__  (               // read TSC, store edx:eax in res
	      "rdtsc\n"
	       : "=a" (end_cycles[0]), "=d" (end_cycles[1]) );
	total_cycles=*((unsigned long long *)end_cycles) - *((unsigned long
long *)start_cycles);
	return total_cycles;
}

             reply	other threads:[~2007-05-03 11:02 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-05-03 11:02 kernel coder [this message]
2007-05-03 16:57 ` Pekka Enberg

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=f69849430705030402v5e737de4sc6ab246a1c64ec0e@mail.gmail.com \
    --to=lhrkernelcoder@gmail.com \
    --cc=linux-kernel@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

all inboxes | Powered by JetHome®