From 23d81904ebafffebec803c2e43bc645dedc88f8e Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 24 Nov 2009 10:18:37 +0100 Subject: RAW-PING-PONG: use timeval_current/timeval_elapsed instead of start_timer/end_timer metze --- source4/torture/raw/pingpong.c | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-) (limited to 'source4/torture/raw/pingpong.c') diff --git a/source4/torture/raw/pingpong.c b/source4/torture/raw/pingpong.c index f620c4854d..124cf69b64 100644 --- a/source4/torture/raw/pingpong.c +++ b/source4/torture/raw/pingpong.c @@ -155,21 +155,6 @@ static void read_byte(struct smbcli_state *cli, int fd, uint8_t *c, int offset) } } - -static struct timeval tp1, tp2; - -static void start_timer(void) -{ - gettimeofday(&tp1, NULL); -} - -static double end_timer(void) -{ - gettimeofday(&tp2, NULL); - return (tp2.tv_sec + (tp2.tv_usec*1.0e-6)) - - (tp1.tv_sec + (tp1.tv_usec*1.0e-6)); -} - /* ping pong */ @@ -187,6 +172,7 @@ bool torture_ping_pong(struct torture_context *torture) uint8_t incr=0, last_incr=0; uint8_t *val; int count, loops; + struct timeval start; fn = torture_setting_string(torture, "filename", NULL); if (fn == NULL) { @@ -219,7 +205,7 @@ bool torture_ping_pong(struct torture_context *torture) lock_byte(cli, fd, 0, lock_timeout); - start_timer(); + start = timeval_current(); val = talloc_zero_array(mem_ctx, uint8_t, num_locks); i = 0; count = 0; @@ -248,11 +234,11 @@ bool torture_ping_pong(struct torture_context *torture) printf("data increment = %u\n", incr); fflush(stdout); } - if (end_timer() > 1.0) { + if (timeval_elapsed(&start) > 1.0) { printf("%8u locks/sec\r", - (unsigned)(2*count/end_timer())); + (unsigned)(2*count/timeval_elapsed(&start))); fflush(stdout); - start_timer(); + start = timeval_current(); count=0; } loops++; -- cgit