summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2009-11-24 10:18:37 +0100
committerStefan Metzmacher <metze@samba.org>2009-11-24 11:47:31 +0100
commit23d81904ebafffebec803c2e43bc645dedc88f8e (patch)
treed4202e110ddd98792e672f387879325463f1c71e /source4
parenta46b63fd98399700183cddb773c85521987ff132 (diff)
downloadsamba-23d81904ebafffebec803c2e43bc645dedc88f8e.tar.gz
samba-23d81904ebafffebec803c2e43bc645dedc88f8e.tar.bz2
samba-23d81904ebafffebec803c2e43bc645dedc88f8e.zip
RAW-PING-PONG: use timeval_current/timeval_elapsed instead of start_timer/end_timer
metze
Diffstat (limited to 'source4')
-rw-r--r--source4/torture/raw/pingpong.c24
1 files changed, 5 insertions, 19 deletions
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++;