Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Re: How many CPU cycles does an instruction take ?

Reply
Thread Tools

Re: How many CPU cycles does an instruction take ?

 
 
Kevin Klein
Guest
Posts: n/a
 
      04-01-2004
One more point:

/5/ Where can I find more indepth tutorial on timing, profiler,
and to help my ignorance, what is on Windows that is not
on linux? Book titles that you KNOW are good. Any faqs, or
tutorials on the net.

How do you
find cpu clock by a certain assembly (gnu assembler) opcode?
Can you tell by its type? while compiling a C code, how can
you get delimited or localized the assembler commands that
a certain C command produces? There may be an indirect hack.

All these multiple questions attack the same problem from
different sides.

Very grateful for any help.

Kevin Klein

 
Reply With Quote
 
 
 
 
Jem Berkes
Guest
Posts: n/a
 
      04-02-2004
> /5/ Where can I find more indepth tutorial on timing, profiler,
> and to help my ignorance, what is on Windows that is not
> on linux? Book titles that you KNOW are good. Any faqs, or
> tutorials on the net.
>
> How do you
> find cpu clock by a certain assembly (gnu assembler) opcode?
> Can you tell by its type? while compiling a C code, how can
> you get delimited or localized the assembler commands that
> a certain C command produces? There may be an indirect hack.


Intel Pentiums and higher, also all modern AMD processors (x86) support the
"rdtsc" instruction (you can call this from inline assembly) which returns
a 64-bit count of the number of CPU clock cycles since powerup. The clock
referred to is the CPU code execution cycle, e.g. a CPU running at 1 GHz
runs through one billion cycles per second.

Under very controlled conditions only, one can use the difference between
two rdtsc counts to measure the clock speed. This is a rather complicated
topic though; you have to keep in mind that this "counter" is global for
the entire computer and lots of other code executes concurrently with your
software.

There are lots of performance-related uses for rdtsc; it is the finest
granularity time interval measure available on a modern PC. If your clock
is running at 4 GHz then rdtsc measures intervals down to 0.25 ns.

--
Jem Berkes
http://www.sysdesign.ca/
 
Reply With Quote
 
 
 
 
those who know me have no need of my name
Guest
Posts: n/a
 
      04-02-2004
in comp.lang.c i read:

>Intel Pentiums and higher, also all modern AMD processors (x86) support the
>"rdtsc" instruction (you can call this from inline assembly)


all of this is off-topic for comp.lang.c and comp.lang.c++.

--
a signature
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Does typecasting consume cpu cycles Vinod Patel C Programming 11 09-17-2004 06:54 AM
How many CPU cycles does an instruction take ? Kevin Klein C++ 4 04-02-2004 03:32 PM
How many CPU cycles does an instruction take ? Kevin Klein C Programming 4 04-02-2004 03:32 PM
Re: How many CPU cycles does an instruction take ? Kevin Klein C Programming 2 04-02-2004 03:23 AM



Advertisments