Ver código fonte

new benchmark runs for 10 seconds.

(Logical change 1.117)


git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@415 fd59a12c-fef9-0310-b244-a6a79926bd2f
Steven Dake 21 anos atrás
pai
commit
a11c169f60
2 arquivos alterados com 55 adições e 29 exclusões
  1. 25 15
      test/ckptbench.c
  2. 30 14
      test/evsbench.c

+ 25 - 15
test/ckptbench.c

@@ -35,6 +35,8 @@
 
 
 #include <stdio.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <stdlib.h>
+#include <signal.h>
+#include <unistd.h>
 #include <errno.h>
 #include <errno.h>
 #include <unistd.h>
 #include <unistd.h>
 #include <time.h>
 #include <time.h>
@@ -43,11 +45,15 @@
 #include <sys/socket.h>
 #include <sys/socket.h>
 #include <sys/select.h>
 #include <sys/select.h>
 #include <sys/un.h>
 #include <sys/un.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
 
 
 #include "ais_types.h"
 #include "ais_types.h"
 #include "ais_ckpt.h"
 #include "ais_ckpt.h"
 
 
-int ckptinv;
+int alarm_notice;
+
 void printSaNameT (SaNameT *name)
 void printSaNameT (SaNameT *name)
 {
 {
 	int i;
 	int i;
@@ -146,16 +152,19 @@ SaCkptIOVectorElementT WriteVectorElements[] = {
 };
 };
 
 
 void ckpt_benchmark (SaCkptCheckpointHandleT checkpointHandle,
 void ckpt_benchmark (SaCkptCheckpointHandleT checkpointHandle,
-	int write_count, int write_size)
+	int write_size)
 {
 {
 	struct timeval tv1, tv2, tv_elapsed;
 	struct timeval tv1, tv2, tv_elapsed;
 	SaUint32T erroroneousVectorIndex = 0;
 	SaUint32T erroroneousVectorIndex = 0;
 	SaErrorT error;
 	SaErrorT error;
+	int write_count = 0;
 
 
+	alarm_notice = 0;
+	alarm (10);
 	WriteVectorElements[0].dataSize = write_size;
 	WriteVectorElements[0].dataSize = write_size;
 
 
 	gettimeofday (&tv1, NULL);
 	gettimeofday (&tv1, NULL);
-	for (ckptinv = 0; ckptinv < write_count; ckptinv++) {
+	do {
 		/*
 		/*
 		 * Test checkpoint write
 		 * Test checkpoint write
 		 */
 		 */
@@ -167,7 +176,8 @@ void ckpt_benchmark (SaCkptCheckpointHandleT checkpointHandle,
 			printf ("saCkptCheckpointWrite result %d (should be 1)\n", error);
 			printf ("saCkptCheckpointWrite result %d (should be 1)\n", error);
 			exit (1);
 			exit (1);
 		}
 		}
-	}
+		write_count += 1;
+	} while (alarm_notice == 0);
 	gettimeofday (&tv2, NULL);
 	gettimeofday (&tv2, NULL);
 	timersub (&tv2, &tv1, &tv_elapsed);
 	timersub (&tv2, &tv1, &tv_elapsed);
 
 
@@ -181,13 +191,19 @@ void ckpt_benchmark (SaCkptCheckpointHandleT checkpointHandle,
 		((float)write_count) * ((float)write_size) /  ((tv_elapsed.tv_sec + (tv_elapsed.tv_usec / 1000000.0)) * 1000000.0));
 		((float)write_count) * ((float)write_size) /  ((tv_elapsed.tv_sec + (tv_elapsed.tv_usec / 1000000.0)) * 1000000.0));
 }
 }
 
 
+void sigalrm_handler (int num)
+{
+	alarm_notice = 1;
+}
+
 int main (void) {
 int main (void) {
 	SaCkptCheckpointHandleT checkpointHandle;
 	SaCkptCheckpointHandleT checkpointHandle;
 	SaErrorT error;
 	SaErrorT error;
 	int size;
 	int size;
-	int count;
 	int i;
 	int i;
 	
 	
+	signal (SIGALRM, sigalrm_handler);
+
 	error = saCkptCheckpointOpen (&checkpointName,
 	error = saCkptCheckpointOpen (&checkpointName,
 		&checkpointCreationAttributes,
 		&checkpointCreationAttributes,
 		SA_CKPT_CHECKPOINT_READ|SA_CKPT_CHECKPOINT_WRITE,
 		SA_CKPT_CHECKPOINT_READ|SA_CKPT_CHECKPOINT_WRITE,
@@ -202,17 +218,11 @@ int main (void) {
 		"Initial Data #0",
 		"Initial Data #0",
 		strlen ("Initial Data #0") + 1);
 		strlen ("Initial Data #0") + 1);
 
 
-	count = 1000;
-	size = 25000;
+	size = 1;
 
 
-	for (i = 0; i < 35; i++) { /* number of repetitions */
-		ckpt_benchmark (checkpointHandle, count, size);
-		/*
-		 * Adjust count to 95% of previous count
-		 * Adjust bytes to write per checkpoint up by 1500
-		 */
-		count = (((float)count) * 0.95);
-		size += 1500;
+	for (i = 0; i < 50; i++) { /* number of repetitions - up to 50k */
+		ckpt_benchmark (checkpointHandle, size);
+		size += 1000;
 	}
 	}
 	return (0);
 	return (0);
 }
 }

+ 30 - 14
test/evsbench.c

@@ -35,6 +35,8 @@
 
 
 #include <stdio.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <stdlib.h>
+#include <signal.h>
+#include <unistd.h>
 #include <errno.h>
 #include <errno.h>
 #include <unistd.h>
 #include <unistd.h>
 #include <time.h>
 #include <time.h>
@@ -50,6 +52,9 @@
 #include "ais_types.h"
 #include "ais_types.h"
 #include "evs.h"
 #include "evs.h"
 
 
+static int alarm_notice = 0;
+
+
 void evs_deliver_fn (struct in_addr source_addr, void *msg, int msg_len)
 void evs_deliver_fn (struct in_addr source_addr, void *msg, int msg_len)
 {
 {
 //	printf ("Delivering message %s\n", buf);
 //	printf ("Delivering message %s\n", buf);
@@ -96,26 +101,31 @@ struct iovec iov = {
 	.iov_len = sizeof (buffer)
 	.iov_len = sizeof (buffer)
 };
 };
 
 
-void ckpt_benchmark (evs_handle_t handle,
-	int write_count, int write_size)
+void evs_benchmark (evs_handle_t handle,
+	int write_size)
 {
 {
 	struct timeval tv1, tv2, tv_elapsed;
 	struct timeval tv1, tv2, tv_elapsed;
 	evs_error_t result;
 	evs_error_t result;
-	int i = 0;
+	int write_count = 0;
 
 
+	/*
+	 * Run benchmark for 10 seconds
+	 */
+	alarm (10);
 	gettimeofday (&tv1, NULL);
 	gettimeofday (&tv1, NULL);
 
 
 	iov.iov_len = write_size;
 	iov.iov_len = write_size;
-	for (i = 0; i < write_count; i++) {
-		sprintf (buffer, "This is message %d\n", i);
+	do {
+		sprintf (buffer, "This is message %d\n", write_count);
 try_again:
 try_again:
 		result = evs_mcast_joined (&handle, EVS_TYPE_AGREED, EVS_PRIO_LOW, &iov, 1);
 		result = evs_mcast_joined (&handle, EVS_TYPE_AGREED, EVS_PRIO_LOW, &iov, 1);
 		if (result == EVS_ERR_TRY_AGAIN) {
 		if (result == EVS_ERR_TRY_AGAIN) {
 			goto try_again;
 			goto try_again;
+		} else {
+			write_count += 1;
 		}
 		}
-	
 		result = evs_dispatch (&handle, EVS_DISPATCH_ALL);
 		result = evs_dispatch (&handle, EVS_DISPATCH_ALL);
-	}
+	} while (alarm_notice == 0);
 	gettimeofday (&tv2, NULL);
 	gettimeofday (&tv2, NULL);
 	timersub (&tv2, &tv1, &tv_elapsed);
 	timersub (&tv2, &tv1, &tv_elapsed);
 
 
@@ -127,15 +137,23 @@ try_again:
 		((float)write_count) /  (tv_elapsed.tv_sec + (tv_elapsed.tv_usec / 1000000.0)));
 		((float)write_count) /  (tv_elapsed.tv_sec + (tv_elapsed.tv_usec / 1000000.0)));
 	printf ("%7.3f MB/s.\n", 
 	printf ("%7.3f MB/s.\n", 
 		((float)write_count) * ((float)write_size) /  ((tv_elapsed.tv_sec + (tv_elapsed.tv_usec / 1000000.0)) * 1000000.0));
 		((float)write_count) * ((float)write_size) /  ((tv_elapsed.tv_sec + (tv_elapsed.tv_usec / 1000000.0)) * 1000000.0));
+
+	alarm_notice = 0;
+}
+
+void sigalrm_handler (int num)
+{
+	alarm_notice = 1;
 }
 }
 
 
 int main (void) {
 int main (void) {
 	int size;
 	int size;
-	int count;
 	int i;
 	int i;
 	evs_error_t result;
 	evs_error_t result;
 	evs_handle_t handle;
 	evs_handle_t handle;
 	
 	
+	signal (SIGALRM, sigalrm_handler);
+
 	result = evs_initialize (&handle, &callbacks);
 	result = evs_initialize (&handle, &callbacks);
 	printf ("Init result %d\n", result);
 	printf ("Init result %d\n", result);
 	result = evs_join (&handle, groups, 3);
 	result = evs_join (&handle, groups, 3);
@@ -143,17 +161,15 @@ int main (void) {
 	result = evs_leave (&handle, &groups[0], 1);
 	result = evs_leave (&handle, &groups[0], 1);
 	printf ("Leave result %d\n", result);
 	printf ("Leave result %d\n", result);
 
 
-	count = 100000;
-	size = 1300;
+	size = 1;
 
 
-	for (i = 0; i < 35; i++) { /* number of repetitions */
-		ckpt_benchmark (handle, count, size);
+	for (i = 0; i < 50; i++) { /* number of repetitions - up to 50k */
+		evs_benchmark (handle, size);
 		/*
 		/*
 		 * Adjust count to 95% of previous count
 		 * Adjust count to 95% of previous count
 		 * Adjust bytes to write per checkpoint up by 1500
 		 * Adjust bytes to write per checkpoint up by 1500
 		 */
 		 */
-		count = (((float)count) * 0.80);
-		size += 100;
+		size += 1000;
 	}
 	}
 	return (0);
 	return (0);
 }
 }