summaryrefslogtreecommitdiff
path: root/source4/torture/local
diff options
context:
space:
mode:
Diffstat (limited to 'source4/torture/local')
-rw-r--r--source4/torture/local/messaging.c10
-rw-r--r--source4/torture/local/talloc.c29
2 files changed, 21 insertions, 18 deletions
diff --git a/source4/torture/local/messaging.c b/source4/torture/local/messaging.c
index c0dab06cca..303ffa8fe9 100644
--- a/source4/torture/local/messaging.c
+++ b/source4/torture/local/messaging.c
@@ -58,6 +58,7 @@ static BOOL test_ping_speed(TALLOC_CTX *mem_ctx)
int ping_count = 0;
int pong_count = 0;
BOOL ret = True;
+ struct timeval tv;
if (fork() == 0) {
struct messaging_context *msg_ctx2 = messaging_init(mem_ctx, 1, ev);
@@ -83,10 +84,10 @@ static BOOL test_ping_speed(TALLOC_CTX *mem_ctx)
messaging_register(msg_ctx, &pong_count, MY_PONG, pong_message);
- start_timer();
+ tv = timeval_current();
printf("Sending pings for 10 seconds\n");
- while (end_timer() < 10.0) {
+ while (timeval_elapsed(&tv) < 10.0) {
DATA_BLOB data;
NTSTATUS status1, status2;
@@ -113,7 +114,7 @@ static BOOL test_ping_speed(TALLOC_CTX *mem_ctx)
printf("waiting for %d remaining replies (done %d)\n",
ping_count - pong_count, pong_count);
- while (end_timer() < 30 && pong_count < ping_count) {
+ while (timeval_elapsed(&tv) < 30 && pong_count < ping_count) {
event_loop_once(ev);
}
@@ -125,7 +126,8 @@ static BOOL test_ping_speed(TALLOC_CTX *mem_ctx)
ret = False;
}
- printf("ping rate of %.0f messages/sec\n", (ping_count+pong_count)/end_timer());
+ printf("ping rate of %.0f messages/sec\n",
+ (ping_count+pong_count)/timeval_elapsed(&tv));
talloc_free(msg_ctx);
diff --git a/source4/torture/local/talloc.c b/source4/torture/local/talloc.c
index 332312200a..348b037753 100644
--- a/source4/torture/local/talloc.c
+++ b/source4/torture/local/talloc.c
@@ -36,18 +36,18 @@
#ifdef _STANDALONE_
typedef enum {False=0,True=1} BOOL;
-static struct timeval tp1,tp2;
-
-static void start_timer(void)
+static struct timeval current_time(void)
{
- gettimeofday(&tp1,NULL);
+ struct timeval tv;
+ GetTimeOfDay(&tv);
+ return tv;
}
-static double end_timer(void)
+static double elapsed_time(struct timeval *tv)
{
- gettimeofday(&tp2,NULL);
- return((tp2.tv_sec - tp1.tv_sec) +
- (tp2.tv_usec - tp1.tv_usec)*1.0e-6);
+ struct timeval tv2 = current_time();
+ return (tv2.tv_sec - tv->tv_sec) +
+ (tv2.tv_usec - tv->tv_usec)*1.0e-6;
}
#endif /* _STANDALONE_ */
@@ -642,10 +642,11 @@ static BOOL test_speed(void)
{
void *ctx = talloc(NULL, 0);
unsigned count;
+ struct timeval tv;
printf("MEASURING TALLOC VS MALLOC SPEED\n");
- start_timer();
+ tv = timeval_current();
count = 0;
do {
void *p1, *p2, *p3;
@@ -654,13 +655,13 @@ static BOOL test_speed(void)
p3 = talloc(p1, 300);
talloc_free(p1);
count += 3;
- } while (end_timer() < 5.0);
+ } while (timeval_elapsed(&tv) < 5.0);
- printf("talloc: %.0f ops/sec\n", count/end_timer());
+ printf("talloc: %.0f ops/sec\n", count/timeval_elapsed(&tv));
talloc_free(ctx);
- start_timer();
+ tv = timeval_current();
count = 0;
do {
void *p1, *p2, *p3;
@@ -671,9 +672,9 @@ static BOOL test_speed(void)
free(p2);
free(p3);
count += 3;
- } while (end_timer() < 5.0);
+ } while (timeval_elapsed(&tv) < 5.0);
- printf("malloc: %.0f ops/sec\n", count/end_timer());
+ printf("malloc: %.0f ops/sec\n", count/timeval_elapsed(&tv));
return True;
}