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 10-07-2006, 01:38 AM   #1
Registered: Sep 2004
Location: NorCal
Distribution: slackware 10.1 comfy, Solaris10 learning
Posts: 232

Rep: Reputation: 31
How to test a run-time of a C program

Hi everyone,

I have two little programs I wrote in C. They both do the same thing but the code is different. How would I go about testing which runs faster?

Last edited by frankie_DJ; 10-07-2006 at 01:39 AM.
Old 10-07-2006, 02:26 AM   #2
Senior Member
Registered: Nov 2003
Location: Perth, Western Australia
Distribution: Ubuntu, Debian, Various using VMWare
Posts: 2,088

Rep: Reputation: 62
Try the "time" program. This is probably only useful if your program does not require user input though.

time ./a.out
and compare the times for each run.
Old 10-07-2006, 05:03 AM   #3
Registered: Jun 2005
Posts: 542

Rep: Reputation: 34
There's time(1) and the shell builtins "time" and "times". Use "help time" and "help times" to see their descriptions.


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
KDE g++ program doesn't run test.cpp richikiki Programming 6 03-17-2006 03:47 PM
How to make a program run at start up time. TruongAn Linux - Software 22 10-26-2005 07:50 PM
i want to run a script or program at boot time!! FreakboY Linux - Newbie 9 10-12-2003 09:03 AM
call other program at run time Xiangbuilder Programming 4 10-01-2003 10:53 AM
compiling kino, gtk test program cant run vance Linux - Software 1 06-02-2003 05:36 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:36 PM.

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