Date: Thu, 2 Mar 2000 20:47:19 -0500 From: Dan Papasian <bugg@bugg.strangled.net> To: current@freebsd.org Subject: which(1), rewritten in C? Message-ID: <20000302204719.A8563@moe.c705742-a.htfdw1.ct.home.com>
next in thread | raw e-mail | index | archive | help
While this may sound crazy, I was tired of 'which' taking a long time to complete on my 486 dx4/100 when it was under extereme pressure, so I rewrote it in C :) I don't think that it is worthwhile replacing this perl script with one written in C, but if anyone is interested... - The overhead of calling perl isn't noticable on most machines - which(1) isn't exactly something that is executed often - Many modern shells have which as a shell built-in. OTOH, that doesn't mean people using /bin/sh should be penalized. - I believe that C is easier to read than perl. Of course, this is a religous argument of sorts, so I don't think that this is a reason to replace it :) BUT IMHO having which be written in C makes it a little bit more consistent with the rest of the source base, and a useful tool no longer depends on perl. OTOH You get a larger binary size with C, and have to compile it. moe% /usr/bin/time ./which perl /usr/bin/perl 0.03 real 0.00 user 0.02 sys moe% /usr/bin/time which perl /usr/bin/perl 0.13 real 0.08 user 0.03 sys NOTE: This version of which has exactly the same behavior. Also, the above test was not performed when the box was under load.. and on slower machines/under load, the differences are of course, more noticable. You may all go ahead and call me crazy now. ...I've got the fear of posting the source, but what the heck, getting nitpicked is good education :) http://bugg.strangled.net/which.c Any flames^Wthoughts? -Dan Papasian <bugg@bugg.strangled.net> To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20000302204719.A8563>