Plan 9 from Bell Labs’s /usr/web/sources/contrib/uriel/changes/2005/0922/20

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


Fix timing computations, increase precision.
 [rsc] --rw-rw-r-- M 191333 glenda sys 9669 Sep 22 19:31 sys/src/cmd/iostats/iostats.c
	/n/sourcesdump/2005/0922/plan9/sys/src/cmd/iostats/iostats.c:144,150 - 
	/n/sourcesdump/2005/0923/plan9/sys/src/cmd/iostats/iostats.c:144,150
	  	stats->rpc[Twstat].name = "wstat";
	  
	  	for(n = 0; n < Maxrpc; n++)
	- 		stats->rpc[n].loms = 10000000;
	+ 		stats->rpc[n].lo = 10000000000LL;
	  
	  	fmtinstall('F', fcallfmt);
	  
	/n/sourcesdump/2005/0922/plan9/sys/src/cmd/iostats/iostats.c:191,200 - 
	/n/sourcesdump/2005/0923/plan9/sys/src/cmd/iostats/iostats.c:191,200
	  		postnote(PNPROC, m->pid, "kill");
	  
	  	rpc = &stats->rpc[Tread];
	- 	brpsec = (float)stats->totread / (((float)rpc->time/1000.0)+.000001);
	+ 	brpsec = (float)stats->totread / (((float)rpc->time/1e9)+.000001);
	  
	  	rpc = &stats->rpc[Twrite];
	- 	bwpsec = (float)stats->totwrite / (((float)rpc->time/1000.0)+.000001);
	+ 	bwpsec = (float)stats->totwrite / (((float)rpc->time/1e9)+.000001);
	  
	  	ttime = 0;
	  	for(n = 0; n < Maxrpc; n++) {
	/n/sourcesdump/2005/0922/plan9/sys/src/cmd/iostats/iostats.c:204,210 - 
	/n/sourcesdump/2005/0923/plan9/sys/src/cmd/iostats/iostats.c:204,210
	  		ttime += rpc->time;
	  	}
	  
	- 	bppsec = (float)stats->nproto / ((ttime/1000.0)+.000001);
	+ 	bppsec = (float)stats->nproto / ((ttime/1e9)+.000001);
	  
	  	fprint(2, "\nread      %lud bytes, %g Kb/sec\n", stats->totread, brpsec/1024.0);
	  	fprint(2, "write     %lud bytes, %g Kb/sec\n", stats->totwrite, bwpsec/1024.0);
	/n/sourcesdump/2005/0922/plan9/sys/src/cmd/iostats/iostats.c:211,217 - 
	/n/sourcesdump/2005/0923/plan9/sys/src/cmd/iostats/iostats.c:211,217
	  	fprint(2, "protocol  %lud bytes, %g Kb/sec\n", stats->nproto, bppsec/1024.0);
	  	fprint(2, "rpc       %lud count\n\n", stats->nrpc);
	  
	- 	fprint(2, "%-10s %5s %5s %5s %5s %5s          in      out\n", 
	+ 	fprint(2, "%-10s %5s %5s %5s %5s %5s          T       R\n", 
	  	      "Message", "Count", "Low", "High", "Time", "Averg");
	  
	  	for(n = 0; n < Maxrpc; n++) {
	/n/sourcesdump/2005/0922/plan9/sys/src/cmd/iostats/iostats.c:218,230 - 
	/n/sourcesdump/2005/0923/plan9/sys/src/cmd/iostats/iostats.c:218,230
	  		rpc = &stats->rpc[n];
	  		if(rpc->count == 0)
	  			continue;
	- 		fprint(2, "%-10s %5lud %5lud %5lud %5lud %5lud ms %8lud %8lud bytes\n", 
	+ 		fprint(2, "%-10s %5lud %5llud %5llud %5llud %5llud ms %8lud %8lud bytes\n", 
	  			rpc->name, 
	  			rpc->count,
	- 			rpc->loms,
	- 			rpc->hims,
	- 			rpc->time,
	- 			rpc->time/rpc->count,
	+ 			rpc->lo/1000000,
	+ 			rpc->hi/1000000,
	+ 			rpc->time/1000000,
	+ 			rpc->time/1000000/rpc->count,
	  			rpc->bin,
	  			rpc->bout);
	  	}
	/n/sourcesdump/2005/0922/plan9/sys/src/cmd/iostats/iostats.c:524,535 - 
	/n/sourcesdump/2005/0923/plan9/sys/src/cmd/iostats/iostats.c:524,529
	  		exits("exit");
	  
	  	noted(NDFLT);
	- }
	- 
	- ulong
	- msec(void)
	- {
	- 	return nsec()/1000000;
	  }
	  
	  void
 [rsc] --rw-rw-r-- M 191333 glenda sys 2617 Sep 22 19:31 sys/src/cmd/iostats/statfs.h
	/n/sourcesdump/2005/0922/plan9/sys/src/cmd/iostats/statfs.h:37,45 - 
	/n/sourcesdump/2005/0923/plan9/sys/src/cmd/iostats/statfs.h:37,45
	  {
	  	char	*name;
	  	ulong	count;
	- 	ulong	time;
	- 	ulong	loms;
	- 	ulong	hims;
	+ 	vlong	time;
	+ 	vlong	lo;
	+ 	vlong	hi;
	  	ulong	bin;
	  	ulong	bout;
	  };
 [rsc] --rw-rw-r-- M 191333 glenda sys 10745 Sep 22 19:31 sys/src/cmd/iostats/statsrv.c
	/n/sourcesdump/2005/0922/plan9/sys/src/cmd/iostats/statsrv.c:32,51 - 
	/n/sourcesdump/2005/0923/plan9/sys/src/cmd/iostats/statsrv.c:32,51
	  }
	  
	  void
	- update(Rpc *rpc, ulong t)
	+ update(Rpc *rpc, vlong t)
	  {
	- 	ulong t2;
	+ 	vlong t2;
	  
	- 	t2 = msec();
	- 	t -= t2;
	- 	if((long)t < 0)
	+ 	t2 = nsec();
	+ 	t = t2 - t;
	+ 	if(t < 0)
	  		t = 0;
	  
	  	rpc->time += t;
	- 	if(t < rpc->loms)
	- 		rpc->loms = t;
	- 	if(t > rpc->hims)
	- 		rpc->hims = t;
	+ 	if(t < rpc->lo)
	+ 		rpc->lo = t;
	+ 	if(t > rpc->hi)
	+ 		rpc->hi = t;
	  }
	  
	  void
	/n/sourcesdump/2005/0922/plan9/sys/src/cmd/iostats/statsrv.c:52,60 - 
	/n/sourcesdump/2005/0923/plan9/sys/src/cmd/iostats/statsrv.c:52,60
	  Xversion(Fsrpc *r)
	  {
	  	Fcall thdr;
	- 	ulong t;
	+ 	vlong t;
	  
	- 	t = msec();
	+ 	t = nsec();
	  
	  	if(r->work.msize > IOHDRSZ+Maxfdata)
	  		thdr.msize = IOHDRSZ+Maxfdata;
	/n/sourcesdump/2005/0922/plan9/sys/src/cmd/iostats/statsrv.c:78,86 - 
	/n/sourcesdump/2005/0923/plan9/sys/src/cmd/iostats/statsrv.c:78,86
	  Xauth(Fsrpc *r)
	  {
	  	Fcall thdr;
	- 	ulong t;
	+ 	vlong t;
	  
	- 	t = msec();
	+ 	t = nsec();
	  
	  	reply(&r->work, &thdr, Enoauth);
	  	r->busy = 0;
	/n/sourcesdump/2005/0922/plan9/sys/src/cmd/iostats/statsrv.c:120,128 - 
	/n/sourcesdump/2005/0923/plan9/sys/src/cmd/iostats/statsrv.c:120,128
	  {
	  	Fcall thdr;
	  	Fid *f;
	- 	ulong t;
	+ 	vlong t;
	  
	- 	t = msec();
	+ 	t = nsec();
	  
	  	f = newfid(r->work.fid);
	  	if(f == 0) {
	/n/sourcesdump/2005/0922/plan9/sys/src/cmd/iostats/statsrv.c:146,155 - 
	/n/sourcesdump/2005/0923/plan9/sys/src/cmd/iostats/statsrv.c:146,155
	  	Fcall thdr;
	  	Fid *f, *n;
	  	File *nf;
	- 	ulong t;
	+ 	vlong t;
	  	int i;
	  
	- 	t = msec();
	+ 	t = nsec();
	  
	  	f = getfid(r->work.fid);
	  	if(f == 0) {
	/n/sourcesdump/2005/0922/plan9/sys/src/cmd/iostats/statsrv.c:217,226 - 
	/n/sourcesdump/2005/0923/plan9/sys/src/cmd/iostats/statsrv.c:217,226
	  {
	  	Fcall thdr;
	  	Fid *f;
	- 	ulong t;
	+ 	vlong t;
	  	int fid;
	  
	- 	t = msec();
	+ 	t = nsec();
	  
	  	f = getfid(r->work.fid);
	  	if(f == 0) {
	/n/sourcesdump/2005/0922/plan9/sys/src/cmd/iostats/statsrv.c:252,260 - 
	/n/sourcesdump/2005/0923/plan9/sys/src/cmd/iostats/statsrv.c:252,260
	  	Fcall thdr;
	  	Fid *f;
	  	int s;
	- 	ulong t;
	+ 	vlong t;
	  
	- 	t = msec();
	+ 	t = nsec();
	  
	  	f = getfid(r->work.fid);
	  	if(f == 0) {
	/n/sourcesdump/2005/0922/plan9/sys/src/cmd/iostats/statsrv.c:296,304 - 
	/n/sourcesdump/2005/0923/plan9/sys/src/cmd/iostats/statsrv.c:296,304
	  	Fcall thdr;
	  	Fid *f;
	  	File *nf;
	- 	ulong t;
	+ 	vlong t;
	  
	- 	t = msec();
	+ 	t = nsec();
	  
	  	f = getfid(r->work.fid);
	  	if(f == 0) {
	/n/sourcesdump/2005/0922/plan9/sys/src/cmd/iostats/statsrv.c:342,350 - 
	/n/sourcesdump/2005/0923/plan9/sys/src/cmd/iostats/statsrv.c:342,350
	  	char err[ERRMAX], path[128];
	  	Fcall thdr;
	  	Fid *f;
	- 	ulong t;
	+ 	vlong t;
	  
	- 	t = msec();
	+ 	t = nsec();
	  
	  	f = getfid(r->work.fid);
	  	if(f == 0) {
	/n/sourcesdump/2005/0922/plan9/sys/src/cmd/iostats/statsrv.c:381,389 - 
	/n/sourcesdump/2005/0923/plan9/sys/src/cmd/iostats/statsrv.c:381,389
	  	Fcall thdr;
	  	Fid *f;
	  	int s;
	- 	ulong t;
	+ 	vlong t;
	  
	- 	t = msec();
	+ 	t = nsec();
	  
	  	f = getfid(r->work.fid);
	  	if(f == 0) {
	/n/sourcesdump/2005/0922/plan9/sys/src/cmd/iostats/statsrv.c:502,512 - 
	/n/sourcesdump/2005/0923/plan9/sys/src/cmd/iostats/statsrv.c:502,512
	  	char err[ERRMAX], path[128];
	  	Fcall *work, thdr;
	  	Fid *f;
	- 	ulong t;
	+ 	vlong t;
	  
	  	work = &p->work;
	  
	- 	t = msec();
	+ 	t = nsec();
	  
	  	f = getfid(work->fid);
	  	if(f == 0) {
	/n/sourcesdump/2005/0922/plan9/sys/src/cmd/iostats/statsrv.c:556,566 - 
	/n/sourcesdump/2005/0923/plan9/sys/src/cmd/iostats/statsrv.c:556,566
	  	Fcall *work, thdr;
	  	Fid *f;
	  	int n, r;
	- 	ulong t;
	+ 	vlong t;
	  
	  	work = &p->work;
	  
	- 	t = msec();
	+ 	t = nsec();
	  
	  	f = getfid(work->fid);
	  	if(f == 0) {
	/n/sourcesdump/2005/0922/plan9/sys/src/cmd/iostats/statsrv.c:618,628 - 
	/n/sourcesdump/2005/0923/plan9/sys/src/cmd/iostats/statsrv.c:618,628
	  	Fcall *work, thdr;
	  	Fid *f;
	  	int n;
	- 	ulong t;
	+ 	vlong t;
	  
	  	work = &p->work;
	  
	- 	t = msec();
	+ 	t = nsec();
	  
	  	f = getfid(work->fid);
	  	if(f == 0) {
 [sys] --rwxrwxr-x M 191333 glenda sys 98431 Sep 22 23:10 386/bin/iostats
	/sys/src/cmd/iostats/iostats.c:catcher
	/sys/src/cmd/iostats/iostats.c:fatal
	/sys/src/cmd/iostats/iostats.c:fidreport
	/sys/src/cmd/iostats/iostats.c:file
	/sys/src/cmd/iostats/iostats.c:getsbuf
	/sys/src/cmd/iostats/iostats.c:initroot
	/sys/src/cmd/iostats/iostats.c:main
	/sys/src/cmd/iostats/iostats.c:makepath
	/sys/src/cmd/iostats/iostats.c:msec
	/sys/src/cmd/iostats/iostats.c:newfid
	/sys/src/cmd/iostats/iostats.c:reply
	/sys/src/cmd/iostats/iostats.c:runprog
	/sys/src/cmd/iostats/iostats.c:strcatalloc
	/sys/src/cmd/iostats/statsrv.c:Xattach
	/sys/src/cmd/iostats/statsrv.c:Xauth
	/sys/src/cmd/iostats/statsrv.c:Xclunk
	/sys/src/cmd/iostats/statsrv.c:Xcreate
	/sys/src/cmd/iostats/statsrv.c:Xremove
	/sys/src/cmd/iostats/statsrv.c:Xstat
	/sys/src/cmd/iostats/statsrv.c:Xversion
	/sys/src/cmd/iostats/statsrv.c:Xwalk
	/sys/src/cmd/iostats/statsrv.c:Xwstat
	/sys/src/cmd/iostats/statsrv.c:slaveopen
	/sys/src/cmd/iostats/statsrv.c:slaveread
	/sys/src/cmd/iostats/statsrv.c:slavewrite
	/sys/src/cmd/iostats/statsrv.c:update
	/sys/src/libc/fmt/fmt.c:_fmtinstall
	/sys/src/libc/fmt/sprint.c:sprint
	/sys/src/libc/port/pool.c:blocksetdsize
	/sys/src/libc/port/pool.c:trim
	/sys/src/libc/port/rune.c:chartorune


Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.