[comp.unix.questions] How fast is script lang. vs. C?

jessea@dynasys.UUCP (Jesse W. Asher) (04/07/90)

Does anyone know the comparative figures on running a shell script
versus running a C program the accomplishes the same thing?  Someone
suggested that it was on the order of 50 to 1, but I have my doubts
that it is _that_ bad.  Anyone got any ideas?  Thanks in advance.


-- 
Jesse W. Asher - Dynasys - (901)382-1705     Evening: (901)382-1609 
6196-1 Macon Rd., Suite 200, Memphis, TN 38134  
UUCP: {fedeva,chromc,autoz}!dynasys!jessea

meadb@boulder.Colorado.EDU (MEAD BENNETT ROSS) (04/09/90)

	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@boulder.colorado.edu |  |  |  |  |  |  |  |  |  |  |  |  |  | 
 |  |  | meadb!tramp!boulder!ncar....   |  |  |  |  |  |  |  |  |  |  |  |  | 
  |  |  |  |meadb!tramp!boulder!sunybcs!rutgers...|  |  |  |  |  |  |  |  |  |