LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
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 06-02-2010, 07:40 AM   #1
himu3118
Member
 
Registered: Mar 2010
Posts: 35

Rep: Reputation: 15
regarding cpu time


i want to find the cpu time taken by an executable to run.. the executable is writting the output to a file. i want to write the time takem by cpu to the same output file.

like:
./abc < input > output

abc is my executable which is taking input as input file and writing the result in output file.. i want to append cpu time information in the same file.

how can i do this..
can i do it with time command??
 
Old 06-02-2010, 08:17 AM   #2
AlucardZero
Senior Member
 
Registered: May 2006
Location: USA
Distribution: Debian
Posts: 4,824

Rep: Reputation: 615Reputation: 615Reputation: 615Reputation: 615Reputation: 615Reputation: 615
Quote:
can i do it with time command??
yes
 
Old 06-02-2010, 08:43 AM   #3
himu3118
Member
 
Registered: Mar 2010
Posts: 35

Original Poster
Rep: Reputation: 15
but how?? wid time??
 
Old 06-02-2010, 09:29 AM   #4
AlucardZero
Senior Member
 
Registered: May 2006
Location: USA
Distribution: Debian
Posts: 4,824

Rep: Reputation: 615Reputation: 615Reputation: 615Reputation: 615Reputation: 615Reputation: 615
Hm, I didn't read your question closely enough or I would have been more helpful.
look at time's -o and -a options.
 
Old 06-02-2010, 09:35 AM   #5
himu3118
Member
 
Registered: Mar 2010
Posts: 35

Original Poster
Rep: Reputation: 15
i have checked those options but its not appending in the same output file..
 
Old 06-02-2010, 04:52 PM   #6
crts
Senior Member
 
Registered: Jan 2010
Posts: 2,020

Rep: Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757
Quote:
Originally Posted by himu3118 View Post
i have checked those options but its not appending in the same output file..
Hi,

this works on my system
Code:
/usr/bin/time -a -o output ./script.sh < input > output
Make sure to give the full path for time. Otherwise bash will use a shell-builtin and this does not understand the -a and -o option.
Hope this helps.
 
  


Reply



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
kacpid eating cpu 99% cpu time! tjclancy Linux - Software 13 09-19-2011 03:08 PM
Convert cpu time to % lavixu Programming 1 12-11-2009 03:24 PM
CPU time for process? m1n Linux - Newbie 3 03-06-2009 06:52 AM
CPU time Vs WALL time, Sometimes Walltime lesser than Cputime ? Options anto.anish Programming 2 10-17-2008 06:33 PM
diff. between elapsed time and cpu time madhugp Linux - General 1 01-15-2007 07:57 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:39 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration