Re: How many CPU cycles does an instruction take ?

Discussion in 'C++' started by Kevin Klein, Apr 1, 2004.

  1. Kevin Klein

    Kevin Klein Guest

    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
     
    Kevin Klein, Apr 1, 2004
    #1
    1. Advertising

  2. Kevin Klein

    Jem Berkes Guest

    > /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/
     
    Jem Berkes, Apr 2, 2004
    #2
    1. Advertising

  3. 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
     
    those who know me have no need of my name, Apr 2, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. -
    Replies:
    7
    Views:
    336
    Kevin McMurtrie
    Mar 22, 2005
  2. Kevin Klein
    Replies:
    4
    Views:
    653
    Dan Pop
    Apr 2, 2004
  3. Kevin Klein

    How many CPU cycles does an instruction take ?

    Kevin Klein, Apr 1, 2004, in forum: C Programming
    Replies:
    4
    Views:
    1,240
    Dan Pop
    Apr 2, 2004
  4. Kevin Klein

    Re: How many CPU cycles does an instruction take ?

    Kevin Klein, Apr 1, 2004, in forum: C Programming
    Replies:
    2
    Views:
    765
    those who know me have no need of my name
    Apr 2, 2004
  5. Vinod Patel

    Does typecasting consume cpu cycles

    Vinod Patel, Sep 14, 2004, in forum: C Programming
    Replies:
    11
    Views:
    725
    Vinod Patel
    Sep 17, 2004
Loading...

Share This Page