From owner-freebsd-current Thu Mar 2 17:45:37 2000 Delivered-To: freebsd-current@freebsd.org Received: from bugg.strangled.net (c705742-a.htfdw1.ct.home.com [24.2.137.94]) by hub.freebsd.org (Postfix) with ESMTP id 84B6B37BD7B for ; Thu, 2 Mar 2000 17:45:32 -0800 (PST) (envelope-from bugg@bugg.strangled.net) Received: (from bugg@localhost) by bugg.strangled.net (8.9.3/8.9.3) id UAA08639 for current@freebsd.org; Thu, 2 Mar 2000 20:47:20 -0500 (EST) (envelope-from bugg) Date: Thu, 2 Mar 2000 20:47:19 -0500 From: Dan Papasian To: current@freebsd.org Subject: which(1), rewritten in C? Message-ID: <20000302204719.A8563@moe.c705742-a.htfdw1.ct.home.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 1.0i Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG 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 To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message