* time
@ 2018-08-11 20:44 Kurt H Maier
0 siblings, 0 replies; only message in thread
From: Kurt H Maier @ 2018-08-11 20:44 UTC (permalink / raw)
To: 9front
Attached is a patch from BurnZeZ that modifies the precision of time(1).
Any objections? I'd like the functionality but I don't want to commit
it without input.
khm
diff -r 5c5acc9ab7a5 sys/src/cmd/time.c
--- a/sys/src/cmd/time.c Sat Aug 11 16:19:32 2018 +0200
+++ b/sys/src/cmd/time.c Sat Aug 11 20:40:06 2018 +0000
@@ -14,16 +14,22 @@
long l;
char *p;
char err[ERRMAX];
+ vlong *t0, t1;
+ enum { SEC = 1000000000ULL };
if(argc <= 1){
fprint(2, "usage: time command\n");
exits("usage");
}
+ if((t0 = segattach(SG_CEXEC, "shared", nil, sizeof(*t0))) == nil)
+ sysfatal("segattach: %r");
+ *t0 = 0;
switch(fork()){
case -1:
error("fork");
case 0:
+ *t0 = nsec();
exec(argv[1], &argv[1]);
if(argv[1][0] != '/' && strncmp(argv[1], "./", 2) &&
strncmp(argv[1], "../", 3)){
@@ -43,12 +49,14 @@
goto loop;
error("wait");
}
+ t1 = nsec();
l = w->time[0];
add("%ld.%.2ldu", l/1000, (l%1000)/10);
l = w->time[1];
add("%ld.%.2lds", l/1000, (l%1000)/10);
l = w->time[2];
add("%ld.%.2ldr", l/1000, (l%1000)/10);
+ add("%lld.%.9lldt", (t1-*t0)/SEC, (t1-*t0)%SEC);
add("\t");
for(i=1; i<argc; i++){
add("%s", argv[i], 0);
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2018-08-11 20:44 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-11 20:44 time Kurt H Maier
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).