From be90385a0b1f8a29c5d181d26c0844f314d04ea7 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 24 Nov 2009 10:59:09 +0100 Subject: [PATCH 1/1] s3:torture: use timeval_current/timeval_elapsed instead of start_timer/end_timer metze --- source3/torture/proto.h | 2 -- source3/torture/torture.c | 50 +++++++++++++++------------------------ 2 files changed, 19 insertions(+), 33 deletions(-) diff --git a/source3/torture/proto.h b/source3/torture/proto.h index 353b98cff31..5d7504abfd8 100644 --- a/source3/torture/proto.h +++ b/source3/torture/proto.h @@ -61,8 +61,6 @@ bool torture_nttrans_scan(int dummy); /* The following definitions come from torture/torture.c */ -void start_timer(void); -double end_timer(void); void *shm_setup(int size); bool smbcli_parse_unc(const char *unc_name, TALLOC_CTX *mem_ctx, char **hostname, char **sharename); diff --git a/source3/torture/torture.c b/source3/torture/torture.c index 5407f3c20ee..39f55590669 100644 --- a/source3/torture/torture.c +++ b/source3/torture/torture.c @@ -49,22 +49,6 @@ bool torture_showall = False; static double create_procs(bool (*fn)(int), bool *result); -static struct timeval tp1,tp2; - - -void start_timer(void) -{ - GetTimeOfDay(&tp1); -} - -double end_timer(void) -{ - GetTimeOfDay(&tp2); - return((tp2.tv_sec - tp1.tv_sec) + - (tp2.tv_usec - tp1.tv_usec)*1.0e-6); -} - - /* return a pointer to a anonymous shared memory segment of size "size" which will persist across fork() but will disappear when all processes exit @@ -2278,6 +2262,7 @@ static bool run_locktest9(int dummy) pid_t child_pid; char c = '\0'; int ret; + struct timeval start; double seconds; NTSTATUS status; @@ -2350,7 +2335,7 @@ static bool run_locktest9(int dummy) CatchSignal(SIGALRM, alarm_handler_parent); alarm(20); - start_timer(); + start = timeval_current(); if (!cli_lock(cli1, fnum, 0, 4, -1, WRITE_LOCK)) { d_fprintf(stderr, "Unable to apply write lock on range 0:4, error was " @@ -2359,7 +2344,7 @@ static bool run_locktest9(int dummy) } alarm(0); - seconds = end_timer(); + seconds = timeval_elapsed(&start); printf("Parent got the lock after %.2f seconds.\n", seconds); @@ -4777,7 +4762,7 @@ static bool run_dirtest(int dummy) int i; static struct cli_state *cli; uint16_t fnum; - double t1; + struct timeval core_start; bool correct = True; printf("starting directory test\n"); @@ -4799,13 +4784,13 @@ static bool run_dirtest(int dummy) cli_close(cli, fnum); } - t1 = end_timer(); + core_start = timeval_current(); printf("Matched %d\n", cli_list(cli, "a*.*", 0, list_fn, NULL)); printf("Matched %d\n", cli_list(cli, "b*.*", 0, list_fn, NULL)); printf("Matched %d\n", cli_list(cli, "xyzabc", 0, list_fn, NULL)); - printf("dirtest core %g seconds\n", end_timer() - t1); + printf("dirtest core %g seconds\n", timeval_elapsed(&core_start)); srandom(0); for (i=0;i