benchmarking c programs

B

Ben

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
 
R

russell kym horsell

Ben said:
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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top