How to create a batch file?
I'm running in Linux, I got a C program which take in a file to do something and the executing time is supposed to be recorded in another file. Right now I have 50 files which the C program need to take in and record their time.
May I know how do I go about doing this? Thanks.... |
You can time the execution of a program using the 'time' utility. Good luck!
|
Thanks for your reply!
But how do I execute them in batches and record the time taken of each file in a RESULT FILE? I'm searching for info on the net now, is it using shell scripting? |
It can be done with shell scripting. What is the command you need to execute and time?
You can just use a basic loop, output redirection, etc. |
This is how my shell scripting pseudo flows:
FOR i = 1 to 50 Write current time to file RESULT Run my C program. The command is "./cb DNA1" // DNA1 is the file that is read in by C program cb, so there is DNA1 to DNA50 Write DNA1 to file RESULT Write current time to file RESULT // so for each loop, i will use the start and stop time to get the actual writing time. Because I am new to shell scripting, can you help me in the code? Thanks for your kind help! I really appreciate it! =) |
Roughly speaking, this should work for you:
Code:
#!/bin/bash |
Whoa! You're GOOD! Thanks man!
Do you know is there any way to obtain the difference in time? E.g. date2 - date1? The completion time minus the starting time? |
Well, you cam get the number of seconds like so:
Code:
START=`date +%s` |
Thanks for your help again! I really appreciate it! :) :D ;)
|
All times are GMT -5. The time now is 08:17 AM. |