Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 20 Oct 2009 08:22:26 -0500
From:      Robert Noland <rnoland@FreeBSD.org>
To:        Ivan Voras <ivoras@freebsd.org>
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: Make process title - % complete
Message-ID:  <1256044946.2386.28.camel@balrog.2hip.net>
In-Reply-To: <hbkb79$7l2$1@ger.gmane.org>
References:  <20091020122432.GA50817@ravenloft.kiev.ua> <hbkb79$7l2$1@ger.gmane.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, 2009-10-20 at 14:42 +0200, Ivan Voras wrote:
> 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).

What is the relative difference in buildworld time with and without?

robert.
 
> ----
> 
> #include <sys/time.h>
> #include <stdlib.h>
> #include <stdio.h>
> #include <string.h>
> #include <unistd.h>
> 
> #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));
> }
> 
> _______________________________________________
> freebsd-hackers@freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
> To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org"
-- 
Robert Noland <rnoland@FreeBSD.org>
FreeBSD




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1256044946.2386.28.camel>