LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices

Reply
 
Search this Thread
Old 10-07-2006, 12:38 AM   #1
frankie_DJ
Member
 
Registered: Sep 2004
Location: NorCal
Distribution: slackware 10.1 comfy, Solaris10 learning
Posts: 232

Rep: Reputation: 30
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 12:39 AM.
 
Old 10-07-2006, 01:26 AM   #2
IBall
Senior Member
 
Registered: Nov 2003
Location: Perth, Western Australia
Distribution: Ubuntu, Debian, Various using VMWare
Posts: 2,088

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

Code:
time ./a.out
and compare the times for each run.
--Ian
 
Old 10-07-2006, 04:03 AM   #3
primo
Member
 
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.
 
  


Reply


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 02:47 PM
How to make a program run at start up time. TruongAn Linux - Software 22 10-26-2005 06:50 PM
i want to run a script or program at boot time!! FreakboY Linux - Newbie 9 10-12-2003 08:03 AM
call other program at run time Xiangbuilder Programming 4 10-01-2003 09:53 AM
compiling kino, gtk test program cant run vance Linux - Software 1 06-02-2003 04:36 AM


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

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