Visit Jeremy's Blog.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 05-04-2005, 10:33 AM   #1
Registered: Feb 2004
Distribution: FC4,RHEL4
Posts: 223

Rep: Reputation: 30
measure program performance

If i wrote a C function then how to know that its costlier in terms of processing time,execution,compilation.
I have written 2 functions for one problem but dont understand which one is best from Opereating System's overhead point of view. so i want tool that measure it.
If this is not right place to ask then tell me where to ask in any other forum.
Old 05-04-2005, 11:49 AM   #2
Registered: Jun 2003
Location: Long Island, NY
Distribution: Gentoo Unstable (what a misnomer)
Posts: 380

Rep: Reputation: 30
Well if you want precise measurements use a profiler like gprof
or oprofile. Otherwise you can get a good idea of the by writing
a simple wrapper program that calls your functions a lot.

/* Anything your functions need */
#include <limits.h>  /* For ULONG_MAX */

int main(int argc, char *argv[])
    for (unsigned long i = 0; i < ULONG_MAX; i++) {
       call_your test_function_here();
    return 0;
Then use the time command to measure performance like so
time ./test_func

Warning depending on your function 2^32 or 2^64 (which depends
on your platforms architechture) may take a long time to complete.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to Measure The Performance After Compiling a modified kernel version 2.4.28 harshcseitbhu Linux - Newbie 1 06-30-2005 04:42 AM
Measure how much I upload and Download barryw Linux - Networking 1 06-02-2005 04:21 AM
wine - program performance kosa Linux - Newbie 2 07-16-2004 08:15 AM
Tool to measure network performance in RedHat9 linux_manual Linux - Networking 0 05-28-2004 10:25 PM
Measure disk performance smokinghound Linux - Hardware 1 07-10-2003 10:58 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:29 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration