benchmarking c programs

Discussion in 'C Programming' started by Ben, Jun 11, 2006.

  1. Ben

    Ben Guest

    Hi,
    I am wondering if there is an easy way to benchmark a c program as a way of measuring the efficiency of the program,
    specifically the number of different instructions performed and total running time.
    I have used other languages where the interpreter has a built-in flag to give you this information but not sure what the
    equivalent is in c.
    cheers,
    Ben
    Ben, Jun 11, 2006
    #1
    1. Advertising

  2. Ben <> wrote:
    > Hi,
    > I am wondering if there is an easy way to benchmark a c program as a way of measuring the efficiency of the program,
    > specifically the number of different instructions performed and total running time.
    > I have used other languages where the interpreter has a built-in flag to give you this information but not sure what the
    > equivalent is in c.
    > cheers,
    > Ben



    Some compilers -- e.g. gcc -- have a "profiling" feature that allow you to
    automatically count the number of times each line/statement is executed.
    If you want to count "instructions" then some x86 processors (and others)
    allow you to setup counters for certain "events" such as instruction fetches
    or memory read/writes. But that is a function of the operating system.


    If you want to measure program runtime and guestimate the number of instructions
    executed (not forgetting with multiple pipeline machines these days, this is
    not to squeezy anymore) then you're also outside the (strictly) C domain
    and into operating system functionality & tools.
    russell kym horsell, Jun 11, 2006
    #2
    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:
    12
    Views:
    1,638
    Dave Thompson
    Jan 10, 2005
  2. Coca
    Replies:
    7
    Views:
    736
    Aidan Grey
    Aug 24, 2004
  3. Replies:
    18
    Views:
    619
    Dave Thompson
    Jan 10, 2005
  4. lone_eagle
    Replies:
    3
    Views:
    632
    psykeedelik
    May 26, 2009
  5. gabriele renzi

    Benchmarking whole programs

    gabriele renzi, Apr 5, 2005, in forum: Ruby
    Replies:
    0
    Views:
    81
    gabriele renzi
    Apr 5, 2005
Loading...

Share This Page