470,826 Members | 1,942 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,826 developers. It's quick & easy.

benchmarking c programs

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
Jun 11 '06 #1
1 1522
Ben <be*********@spam.me> 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.
Jun 11 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Dean J. Garrett | last post: by
reply views Thread by Rob | last post: by
1 post views Thread by Trevor Best | last post: by
3 posts views Thread by Andy Dingley | last post: by
6 posts views Thread by Jens Himmelreich | last post: by
8 posts views Thread by Jerry Coffin | last post: by
reply views Thread by Cyrille \cns\ Szymanski | last post: by
10 posts views Thread by Michel Rouzic | last post: by
reply views Thread by mihailmihai484 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.