svn rev #23141: trunk/src/tests/threads/

raeburn@MIT.EDU raeburn at MIT.EDU
Fri Nov 6 19:14:33 EST 2009


http://src.mit.edu/fisheye/changelog/krb5/?cs=23141
Commit By: raeburn
Log Message:
Delay start of test until the start of a new second on the system
clock.  Print per-thread stats only once.


Changed Files:
U   trunk/src/tests/threads/t_rcache.c
Modified: trunk/src/tests/threads/t_rcache.c
===================================================================
--- trunk/src/tests/threads/t_rcache.c	2009-11-06 23:29:12 UTC (rev 23140)
+++ trunk/src/tests/threads/t_rcache.c	2009-11-07 00:14:33 UTC (rev 23141)
@@ -52,7 +52,17 @@
 int init_once = 0;
 int n_threads = 2;
 int interval = 20 /* 5 * 60 */;
+int *ip;
 
+static void wait_for_tick ()
+{
+    time_t now, next;
+    now = time(0);
+    do {
+	next = time(0);
+    } while (now == next);
+}
+
 static void try_one (struct tinfo *t)
 {
     krb5_donot_replay r;
@@ -113,7 +123,7 @@
 /*	printf("%c", chr); */
 	fflush(stdout);
     }
-    printf("thread %p total %u\n", &t, t.total);
+/*    printf("thread %u total %u\n", (unsigned) ((int *)x-ip), t.total);*/
     *(int*)x = t.total;
     return 0;
 }
@@ -161,7 +171,7 @@
 int main (int argc, char *argv[])
 {
     krb5_error_code err;
-    int i, *ip;
+    int i;
 
     process_options (argc, argv);
     err = krb5_init_context(&ctx);
@@ -203,7 +213,6 @@
 	    return 1;
 	}
     }
-    end_time = time(0) + interval;
 
     ip = malloc(sizeof(int) * n_threads);
     if (ip == 0 && n_threads > 0) {
@@ -213,6 +222,9 @@
     for (i = 0; i < n_threads; i++)
 	ip[i] = i;
 
+    wait_for_tick ();
+    end_time = time(0) + interval;
+
     for (i = 0; i < n_threads; i++) {
 	pthread_t new_thread;
 	int perr;
@@ -226,7 +238,8 @@
     while (time(0) < end_time + 1)
 	sleep(1);
     for (i = 0; i < n_threads; i++)
-	printf("thread %d total %5d\n", i, ip[i]);
+	printf("thread %d total %5d, about %.1f per second\n", i, ip[i],
+	       ((double) ip[i])/interval);
     free(ip);
 
     if (init_once)




More information about the cvs-krb5 mailing list