How fast is script lang. vs. C?

MEAD BENNETT ROSS meadb at boulder.Colorado.EDU
Mon Apr 9 05:30:58 AEST 1990


	I dont know exactly how bad cshell-script is, but if you do it wrong it
can take ages.  I have a program that prints out how long I was on the system,
and when I got on.  I won't include the script here because it is quite long,
but I'll describe how I do it.  The script greps the `who` list for my login,
then takes out the time I got on.  It then takes both the current time and the
time I got on and splits them up into minutes and hours.  It pipes these to dc
to get the difference between each element (hours and minutes), and deals with
the special cases.  (on at 3:59, off at 4:01, causes problems)  Finally it 
echoes it to a file or to the screen.  This takes 5 seconds.  
	Now it is programmed it in C, getting the various numbers from 
/etc/utmp, and time ();, subtracting the two long ints, and converting the 
difference to hours and minutes.  This is untimeable for one iteration.  (i.e.
< 0.1 seconds.)  Assuming it takes .05 seconds (just a wild guess, but it 
appears to execute instantly.) that is a difference of 100 times.  O.K. my 
Shell script may be rather brain dead, but I couldn't figure out how to do it
any other way.  (Yes I RTFM frequently.)
				This may not be typical, but I hope it helps.
						-Bennett

|  |  meadb%tramp at boulder.colorado.edu |  |  |  |  |  |  |  |  |  |  |  |  |  | 
 |  |  | meadb!tramp!boulder!ncar....   |  |  |  |  |  |  |  |  |  |  |  |  | 
  |  |  |  |meadb!tramp!boulder!sunybcs!rutgers...|  |  |  |  |  |  |  |  |  |



More information about the Comp.unix.questions mailing list