Re: tftp: use monotonic clock for statistics summary
OK by me On 10 Sep. 2017 5:21 am, "Theo Buehler"wrote: > On Sat, Sep 09, 2017 at 04:28:45PM +, Scott Cheloha wrote: > > 3 week bump. > > looks good to me. > > anyone willing to ok this or commit this with my ok? > > > > > -- > > Scott Cheloha > > > > > On Aug 16, 2017, at 8:46 PM, Scott Cheloha > wrote: > > > > > > Hi, > > > > > > Same deal here as in dd(1). We display the elapsed time so we want > > > a monotonic clock. > > > > > > -- > > > Scott Cheloha > > > > > > Index: usr.bin/tftp/tftp.c > > > === > > > RCS file: /cvs/src/usr.bin/tftp/tftp.c,v > > > retrieving revision 1.24 > > > diff -u -p -r1.24 tftp.c > > > --- usr.bin/tftp/tftp.c 21 Oct 2014 06:15:16 - 1.24 > > > +++ usr.bin/tftp/tftp.c 17 Aug 2017 01:44:46 - > > > @@ -52,6 +52,7 @@ > > > #include > > > #include > > > #include > > > +#include > > > #include > > > #include > > > > > > @@ -83,8 +84,8 @@ extern int opt_tsize; > > > extern int opt_tout; > > > extern int opt_blksize; > > > > > > -struct timeval tstart; > > > -struct timeval tstop; > > > +struct timespectstart; > > > +struct timespectstop; > > > unsigned intsegment_size = SEGSIZE; > > > unsigned intpacket_size = SEGSIZE + 4; > > > > > > @@ -548,13 +549,13 @@ tpacket(const char *s, struct tftphdr *t > > > static void > > > startclock(void) > > > { > > > - (void)gettimeofday(, NULL); > > > + clock_gettime(CLOCK_MONOTONIC, ); > > > } > > > > > > static void > > > stopclock(void) > > > { > > > - (void)gettimeofday(, NULL); > > > + clock_gettime(CLOCK_MONOTONIC, ); > > > } > > > > > > static void > > > @@ -563,8 +564,8 @@ printstats(const char *direction, unsign > > > double delta; > > > > > > /* compute delta in 1/10's second units */ > > > - delta = ((tstop.tv_sec * 10.) + (tstop.tv_usec / 10)) - > > > - ((tstart.tv_sec * 10.) + (tstart.tv_usec / 10)); > > > + delta = ((tstop.tv_sec * 10.) + (tstop.tv_nsec / 1)) - > > > + ((tstart.tv_sec * 10.) + (tstart.tv_nsec / 1)); > > > delta = delta / 10.;/* back to seconds */ > > > printf("%s %lu bytes in %.1f seconds", direction, amount, delta); > > > if (verbose) > > > >
Re: tftp: use monotonic clock for statistics summary
On Sat, Sep 09, 2017 at 04:28:45PM +, Scott Cheloha wrote: > 3 week bump. looks good to me. anyone willing to ok this or commit this with my ok? > > -- > Scott Cheloha > > > On Aug 16, 2017, at 8:46 PM, Scott Chelohawrote: > > > > Hi, > > > > Same deal here as in dd(1). We display the elapsed time so we want > > a monotonic clock. > > > > -- > > Scott Cheloha > > > > Index: usr.bin/tftp/tftp.c > > === > > RCS file: /cvs/src/usr.bin/tftp/tftp.c,v > > retrieving revision 1.24 > > diff -u -p -r1.24 tftp.c > > --- usr.bin/tftp/tftp.c 21 Oct 2014 06:15:16 - 1.24 > > +++ usr.bin/tftp/tftp.c 17 Aug 2017 01:44:46 - > > @@ -52,6 +52,7 @@ > > #include > > #include > > #include > > +#include > > #include > > #include > > > > @@ -83,8 +84,8 @@ extern int opt_tsize; > > extern int opt_tout; > > extern int opt_blksize; > > > > -struct timeval tstart; > > -struct timeval tstop; > > +struct timespectstart; > > +struct timespectstop; > > unsigned intsegment_size = SEGSIZE; > > unsigned intpacket_size = SEGSIZE + 4; > > > > @@ -548,13 +549,13 @@ tpacket(const char *s, struct tftphdr *t > > static void > > startclock(void) > > { > > - (void)gettimeofday(, NULL); > > + clock_gettime(CLOCK_MONOTONIC, ); > > } > > > > static void > > stopclock(void) > > { > > - (void)gettimeofday(, NULL); > > + clock_gettime(CLOCK_MONOTONIC, ); > > } > > > > static void > > @@ -563,8 +564,8 @@ printstats(const char *direction, unsign > > double delta; > > > > /* compute delta in 1/10's second units */ > > - delta = ((tstop.tv_sec * 10.) + (tstop.tv_usec / 10)) - > > - ((tstart.tv_sec * 10.) + (tstart.tv_usec / 10)); > > + delta = ((tstop.tv_sec * 10.) + (tstop.tv_nsec / 1)) - > > + ((tstart.tv_sec * 10.) + (tstart.tv_nsec / 1)); > > delta = delta / 10.;/* back to seconds */ > > printf("%s %lu bytes in %.1f seconds", direction, amount, delta); > > if (verbose) >
Re: tftp: use monotonic clock for statistics summary
3 week bump. -- Scott Cheloha > On Aug 16, 2017, at 8:46 PM, Scott Chelohawrote: > > Hi, > > Same deal here as in dd(1). We display the elapsed time so we want > a monotonic clock. > > -- > Scott Cheloha > > Index: usr.bin/tftp/tftp.c > === > RCS file: /cvs/src/usr.bin/tftp/tftp.c,v > retrieving revision 1.24 > diff -u -p -r1.24 tftp.c > --- usr.bin/tftp/tftp.c 21 Oct 2014 06:15:16 - 1.24 > +++ usr.bin/tftp/tftp.c 17 Aug 2017 01:44:46 - > @@ -52,6 +52,7 @@ > #include > #include > #include > +#include > #include > #include > > @@ -83,8 +84,8 @@ extern int opt_tsize; > extern int opt_tout; > extern int opt_blksize; > > -struct timeval tstart; > -struct timeval tstop; > +struct timespec tstart; > +struct timespec tstop; > unsigned int segment_size = SEGSIZE; > unsigned int packet_size = SEGSIZE + 4; > > @@ -548,13 +549,13 @@ tpacket(const char *s, struct tftphdr *t > static void > startclock(void) > { > - (void)gettimeofday(, NULL); > + clock_gettime(CLOCK_MONOTONIC, ); > } > > static void > stopclock(void) > { > - (void)gettimeofday(, NULL); > + clock_gettime(CLOCK_MONOTONIC, ); > } > > static void > @@ -563,8 +564,8 @@ printstats(const char *direction, unsign > double delta; > > /* compute delta in 1/10's second units */ > - delta = ((tstop.tv_sec * 10.) + (tstop.tv_usec / 10)) - > - ((tstart.tv_sec * 10.) + (tstart.tv_usec / 10)); > + delta = ((tstop.tv_sec * 10.) + (tstop.tv_nsec / 1)) - > + ((tstart.tv_sec * 10.) + (tstart.tv_nsec / 1)); > delta = delta / 10.;/* back to seconds */ > printf("%s %lu bytes in %.1f seconds", direction, amount, delta); > if (verbose)
tftp: use monotonic clock for statistics summary
Hi, Same deal here as in dd(1). We display the elapsed time so we want a monotonic clock. -- Scott Cheloha Index: usr.bin/tftp/tftp.c === RCS file: /cvs/src/usr.bin/tftp/tftp.c,v retrieving revision 1.24 diff -u -p -r1.24 tftp.c --- usr.bin/tftp/tftp.c 21 Oct 2014 06:15:16 - 1.24 +++ usr.bin/tftp/tftp.c 17 Aug 2017 01:44:46 - @@ -52,6 +52,7 @@ #include #include #include +#include #include #include @@ -83,8 +84,8 @@ extern int opt_tsize; extern int opt_tout; extern int opt_blksize; -struct timeval tstart; -struct timeval tstop; +struct timespectstart; +struct timespectstop; unsigned int segment_size = SEGSIZE; unsigned int packet_size = SEGSIZE + 4; @@ -548,13 +549,13 @@ tpacket(const char *s, struct tftphdr *t static void startclock(void) { - (void)gettimeofday(, NULL); + clock_gettime(CLOCK_MONOTONIC, ); } static void stopclock(void) { - (void)gettimeofday(, NULL); + clock_gettime(CLOCK_MONOTONIC, ); } static void @@ -563,8 +564,8 @@ printstats(const char *direction, unsign double delta; /* compute delta in 1/10's second units */ - delta = ((tstop.tv_sec * 10.) + (tstop.tv_usec / 10)) - - ((tstart.tv_sec * 10.) + (tstart.tv_usec / 10)); + delta = ((tstop.tv_sec * 10.) + (tstop.tv_nsec / 1)) - + ((tstart.tv_sec * 10.) + (tstart.tv_nsec / 1)); delta = delta / 10.;/* back to seconds */ printf("%s %lu bytes in %.1f seconds", direction, amount, delta); if (verbose)