Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!ncar!boulder!meadb From: meadb@boulder.Colorado.EDU (MEAD BENNETT ROSS) Newsgroups: comp.unix.questions Subject: Re: How fast is script lang. vs. C? Message-ID: <19422@boulder.Colorado.EDU> Date: 8 Apr 90 19:30:58 GMT References: <135@dynasys.UUCP> Sender: news@boulder.Colorado.EDU Reply-To: meadb@boulder.Colorado.EDU (Bennett Ross Mead) Organization: University of Colorado, boulder Lines: 23 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...| | | | | | | | | |