From owner-freebsd-hackers@FreeBSD.ORG Tue Oct 20 12:42:54 2009 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E588B1065672 for ; Tue, 20 Oct 2009 12:42:54 +0000 (UTC) (envelope-from freebsd-hackers@m.gmane.org) Received: from lo.gmane.org (lo.gmane.org [80.91.229.12]) by mx1.freebsd.org (Postfix) with ESMTP id A2FFC8FC16 for ; Tue, 20 Oct 2009 12:42:54 +0000 (UTC) Received: from list by lo.gmane.org with local (Exim 4.50) id 1N0E31-000652-G3 for freebsd-hackers@freebsd.org; Tue, 20 Oct 2009 14:42:43 +0200 Received: from lara.cc.fer.hr ([161.53.72.113]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 20 Oct 2009 14:42:43 +0200 Received: from ivoras by lara.cc.fer.hr with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 20 Oct 2009 14:42:43 +0200 X-Injected-Via-Gmane: http://gmane.org/ To: freebsd-hackers@freebsd.org From: Ivan Voras Date: Tue, 20 Oct 2009 14:42:17 +0200 Lines: 53 Message-ID: References: <20091020122432.GA50817@ravenloft.kiev.ua> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: lara.cc.fer.hr User-Agent: Thunderbird 2.0.0.23 (X11/20090928) In-Reply-To: <20091020122432.GA50817@ravenloft.kiev.ua> Sender: news Subject: Re: Make process title - % complete X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 20 Oct 2009 12:42:55 -0000 Alex Kozlov wrote: > Of course ps or top output much more convenient, but if setproctitle so > expencive and will be called so often, then SIGINFO may be good > compromise. Regarding speed of setproctitle(), here are some microbenchmark results from the attached test source: getpid: 3661124.75 iterations/s setproctitle: 591357.56 iterations/s Meaning, setprocitle() is around 6 times more expensive than getpid(), meaning it can only be pulled off nearly 600,000 calls/s on a 2.3 GHz Core 2 CPU. I really want to be enlightened about how it could affect wallclock time in make(1). ---- #include #include #include #include #include #define NITER 1e7 double now() { struct timeval tp; gettimeofday(&tp, NULL); return tp.tv_sec + (double)tp.tv_usec / 1e6f; } int main() { double t1, t2, t3; int i; t1 = now(); for (i = 0; i < NITER; i++) getpid(); t2 = now() - t1; printf("getpid: %0.2f iterations/s\n", (float)(NITER/t2)); t1 = now(); for (i = 0; i < NITER; i++) setproctitle("t%d", i); t3 = now() - t1; printf("setproctitle: %0.2f iterations/s\n", (float)(NITER/t3)); }