igb@fulcrum.bt.co.uk (Ian G Batten) (01/15/91)
In article <1991Jan14.202053.20054@zoo.toronto.edu> henry@zoo.toronto.edu (Henry Spencer) writes: > Incidentally, it turns out that one can often rewrite Berkeley or AT&T > C programs as shell files and find that they run *faster*. I don't doubt it. I had to use ``sum'' in a small utility and was shocked at its performance. When I rewrote it as a function --- rather than running it down a pipe --- and removed some obvious infelicitudes it ran about three times faster. That with, oh, half an hour's effort. Script started on Tue Jan 15 09:27:34 1991 $ time sum /unix 23454 2098 /unix real 3.2 user 2.3 sys 0.8 $ time ./csm /unix 23454 2098 real 1.1 user 0.3 sys 0.7 $ script done on Tue Jan 15 09:27:53 1991 Other commands are as bad. [[ This on a machine using gcc as the only compiler, as well! ]] ian
jfh@rpp386.cactus.org (John F Haugh II) (01/15/91)
In article <BW2^?6-@uzi-9mm.fulcrum.bt.co.uk> igb@fulcrum.bt.co.uk (Ian G Batten) writes: >I don't doubt it. I had to use ``sum'' in a small utility and was >shocked at its performance. When I rewrote it as a function --- rather >than running it down a pipe --- and removed some obvious infelicitudes >it ran about three times faster. That with, oh, half an hour's effort. Well, I do doubt it. Here is a collection of examples. It should be obvious that the pipe loses out over the single C command. Of course, on a system with a load average <1, waste is just fine. % timex who -q jfh jfh jfh root # users=4 execution complete real 0.18 user 0.02 sys 0.08 % timex users jfh root execution complete real 0.19 user 0.00 sys 0.05 % timex /bin/sh -c 'who | cut -d" " -f1 | sort -u | tr \\012 " " ; echo ""' jfh root execution complete real 0.79 user 0.02 sys 0.22 -- John F. Haugh II UUCP: ...!cs.utexas.edu!rpp386!jfh Ma Bell: (512) 832-8832 Domain: jfh@rpp386.cactus.org "While you are here, your wives and girlfriends are dating handsome American movie and TV stars. Stars like Tom Selleck, Bruce Willis, and Bart Simpson."
henry@zoo.toronto.edu (Henry Spencer) (01/16/91)
In article <18948@rpp386.cactus.org> jfh@rpp386.cactus.org (John F Haugh II) writes: >% timex users >jfh root >execution complete > >real 0.19 >user 0.00 >sys 0.05 >% timex /bin/sh -c 'who | cut -d" " -f1 | sort -u | tr \\012 " " ; echo ""' >jfh root >execution complete > >real 0.79 >user 0.02 >sys 0.22 [begin sarcasm] I am truly awed at the magnitude of the resource saving here. Clearly saving 190 milliseconds of CPU time, and about half a second of real time, on a command used a few dozen times a day is of enormous importance. [end sarcasm] We didn't think savings of this magnitude worthwhile on our poor struggling old pdp11/44, never mind on a modern machine. Not when it added substantial programming and maintenance overhead forevermore. -- If the Space Shuttle was the answer, | Henry Spencer at U of Toronto Zoology what was the question? | henry@zoo.toronto.edu utzoo!henry
gwyn@smoke.brl.mil (Doug Gwyn) (01/16/91)
In article <18948@rpp386.cactus.org> jfh@rpp386.cactus.org (John F Haugh II) writes: >Well, I do doubt it. Here is a collection of examples. It should be >obvious that the pipe loses out over the single C command. Sure, running the general merge-sort utility sure slows it down. But 'who|wc -l' is so close in performance on this (relatively puny) system that it would take a practically infinite number of invocations before it would repay the resources that would have to be spent to install the special-purpose who -q hack. That, after all, was the point of the comments against such hacks.