Re: tcpbench: Don't use floating precision while printing PPS in UDP mode.

2012-01-29 Thread Lawrence Teo
On Sun, Jan 29, 2012 at 12:55:56AM -0200, Christiano F. Haesbaert wrote:
> Moin, 
> 
> I think it doesn't make sense for PPS, also, the rounding is wrong so we 
> always get .000
> 
> This makes the output go from:
> Elapsed:   11685 Mbps:  63.602 Peak Mbps:  63.602 Rx PPS:   
> 5401.000
> 
> to:
> Elapsed:   15000 Mbps:1227.177 Peak Mbps:1245.347 Tx PPS:  104210
> 
> ok ?

I tested your diff and the new output makes a lot of sense to me. Easier
for scripts to parse too. :)

I obviously can't ok it but I like it. :)

Thanks,
Lawrence



tcpbench: Don't use floating precision while printing PPS in UDP mode.

2012-01-28 Thread Christiano F. Haesbaert
Moin, 

I think it doesn't make sense for PPS, also, the rounding is wrong so we always 
get .000

This makes the output go from:
Elapsed:   11685 Mbps:  63.602 Peak Mbps:  63.602 Rx PPS:   5401.000

to:
Elapsed:   15000 Mbps:1227.177 Peak Mbps:1245.347 Tx PPS:  104210

ok ?

Index: tcpbench.c
===
RCS file: /cvs/src/usr.bin/tcpbench/tcpbench.c,v
retrieving revision 1.30
diff -d -u -p -w -r1.30 tcpbench.c
--- tcpbench.c  26 Jan 2012 17:53:53 -  1.30
+++ tcpbench.c  29 Jan 2012 02:47:38 -
@@ -571,8 +571,8 @@ static void
 udp_process_slice(int fd, short event, void *v_sc)
 {
struct statctx *sc = v_sc;
-   unsigned long long total_elapsed, since_last;
-   long double slice_mbps, pps;
+   unsigned long long total_elapsed, since_last, pps;
+   long double slice_mbps;
struct timeval t_cur, t_diff;
 
if (clock_gettime_tv(CLOCK_MONOTONIC, &t_cur) == -1)
@@ -586,7 +586,7 @@ udp_process_slice(int fd, short event, v
pps = (sc->udp_slice_pkts * 1000) / since_last;
if (slice_mbps > mainstats.peak_mbps)
mainstats.peak_mbps = slice_mbps;
-   printf("Elapsed: %11llu Mbps: %11.3Lf Peak Mbps: %11.3Lf %s PPS: 
%10.3Lf\n",
+   printf("Elapsed: %11llu Mbps: %11.3Lf Peak Mbps: %11.3Lf %s PPS: 
%7llu\n",
total_elapsed, slice_mbps, mainstats.peak_mbps,
ptb->sflag ? "Rx" : "Tx", pps);