[httperf] httperf benchmarking and reporting

Theodore Bullock tbullock at canada.com
Fri Jul 25 11:29:38 PDT 2008


On Fri, 2008-07-25 at 19:33 +0400, Sergey Vidyuk wrote:
> Is csv or key=value output have been added to trunk>?

Below is an "INCOMPLETE" patch to add csv output (applies to today's
CVS).  I'm not willing to finish it by the end of the month (renovating
my new condo instead), but will get it complete in the within the first
week of August otherwise.  If anyone wants to pickup where I left off
and complete it earlier, you are welcome too.

:)

? man/idleconn.1
Index: src/httperf.c
===================================================================
RCS file: /cvsroot/httperf/httperf/src/httperf.c,v
retrieving revision 1.24
diff -u -r1.24 httperf.c
--- src/httperf.c	15 Jul 2008 20:52:08 -0000	1.24
+++ src/httperf.c	25 Jul 2008 18:22:47 -0000
@@ -62,7 +62,6 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <unistd.h>
 
 #ifdef __FreeBSD__
 /* Required for fpsetmask() under FreeBSD */
@@ -73,6 +72,8 @@
 
 #include <generic_types.h>
 #include <sys/resource.h>	/* after sys/types.h for BSD (in generic_types.h) */
+#include <sys/stat.h>
+#include <unistd.h>
 #include <event.h>
 
 #include <object.h>
@@ -82,6 +83,7 @@
 #include <core.h>
 #include <localevent.h>
 #include <httperf.h>
+#include <stats.h>
 
 
 #ifdef HAVE_SSL
@@ -152,6 +154,7 @@
 	{"wsesslog", required_argument, (int *) &param.wsesslog, 0},
 	{"wsesspage", required_argument, (int *) &param.wsesspage, 0},
 	{"wset", required_argument, (int *) &param.wset, 0},
+	{"csv-results-file", required_argument, (int *) &param.csv_results_file, 0},
 	{0, 0, 0, 0}
 };
 
@@ -177,7 +180,7 @@
 	       "\t[--wlog y|n,file] [--wsess N,N,X] [--wsesslog N,X,file]\n"
 	       "\t[--wset N,X]\n"
 	       "\t[--period [v]T1,D1[,T2,D2]\n"
-	       "\t[--use-timer-cache]\n", prog_name);
+	       "\t[--use-timer-cache] [--csv-results-file file]\n", prog_name);
 }
 
 void
@@ -230,7 +233,7 @@
 		&conn_rate,
 	};
 	int             num_stats = 1;
-	Stat_Collector *stat[3] = {
+	Stat_Collector *sc_stat[3] = {
 		&stats_basic
 	};
 	int             i, ch, longindex;
@@ -633,6 +636,25 @@
 #endif
 			else if (flag == &param.uri)
 				param.uri = optarg;
+			else if (flag == &param.csv_results_file) {
+				struct stat sb;
+				param.csv_results_file = optarg;
+				/* Test if file exists */
+				if (stat(param.csv_results_file, &sb) == -1) {
+					if(errno == ENOENT)
+						csv_results_file_exists = false;
+					else
+						panic ("%s: cannot access %s\n", prog_name,
+							   param.csv_results_file);
+				}
+				else
+					csv_results_file_exists = true;
+				
+				csv_results_file_fp = fopen (param.csv_results_file, "a");
+				if (csv_results_file_fp == NULL)
+					panic ("%s: cannot open %s for writing\n", prog_name,
+						   param.csv_results_file);  
+			}
 			else if (flag == &param.think_timeout) {
 				errno = 0;
 				param.think_timeout = strtod(optarg, &end);
@@ -662,7 +684,7 @@
 				num_gen = 2;	/* XXX fix me---somehow */
 				gen[0] = &wsess;
 
-				stat[num_stats++] = &session_stat;
+				sc_stat[num_stats++] = &session_stat;
 
 				errno = 0;
 				name = "bad number of sessions (1st param)";
@@ -710,7 +732,7 @@
 				num_gen = 2;	/* XXX fix me---somehow */
 				gen[0] = &wsesspage;
 
-				stat[num_stats++] = &session_stat;
+				sc_stat[num_stats++] = &session_stat;
 
 				errno = 0;
 				name = "bad number of sessions (1st param)";
@@ -759,7 +781,7 @@
 				num_gen = 1;	/* XXX fix me---somehow */
 				gen[0] = &wsesslog;
 
-				stat[num_stats++] = &session_stat;
+				sc_stat[num_stats++] = &session_stat;
 
 				errno = 0;
 				name = "bad number of sessions (1st param)";
@@ -941,7 +963,7 @@
 		param.port = 80;
 
 	if (param.print_reply || param.print_request)
-		stat[num_stats++] = &stats_print_reply;
+		sc_stat[num_stats++] = &stats_print_reply;
 
 	if (param.session_cookies) {
 		if (!session_workload) {
@@ -1111,7 +1133,7 @@
 	signal(SIGINT, (void (*)()) core_exit);
 
 	for (i = 0; i < num_stats; ++i)
-		(*stat[i]->init) ();
+		(*sc_stat[i]->init) ();
 	for (i = 0; i < num_gen; ++i)
 		(*gen[i]->init) ();
 
@@ -1132,7 +1154,7 @@
 	for (i = 0; i < num_gen; ++i)
 		(*gen[i]->start) ();
 	for (i = 0; i < num_stats; ++i)
-		(*stat[i]->start) ();
+		(*sc_stat[i]->start) ();
 
 	getrusage(RUSAGE_SELF, &test_rusage_start);
 	test_time_start = timer_now();
@@ -1141,11 +1163,11 @@
 	getrusage(RUSAGE_SELF, &test_rusage_stop);
 
 	for (i = 0; i < num_stats; ++i)
-		(*stat[i]->stop) ();
+		(*sc_stat[i]->stop) ();
 	for (i = 0; i < num_gen; ++i)
 		(*gen[i]->stop) ();
 	for (i = 0; i < num_stats; ++i)
-		(*stat[i]->dump) ();
+		(*sc_stat[i]->dump) ();
 
 	timer_free_all();
 
Index: src/httperf.h
===================================================================
RCS file: /cvsroot/httperf/httperf/src/httperf.h,v
retrieving revision 1.7
diff -u -r1.7 httperf.h
--- src/httperf.h	15 Jul 2007 21:14:20 -0000	1.7
+++ src/httperf.h	25 Jul 2008 18:22:47 -0000
@@ -161,6 +161,7 @@
 	double target_miss_rate;
       }
     wset;
+	const char *csv_results_file; /* run results saved here in csv format */
   }
 Cmdline_Params;
 
Index: src/stat/basic.c
===================================================================
RCS file: /cvsroot/httperf/httperf/src/stat/basic.c,v
retrieving revision 1.10
diff -u -r1.10 basic.c
--- src/stat/basic.c	15 Jul 2008 20:52:11 -0000	1.10
+++ src/stat/basic.c	25 Jul 2008 18:22:47 -0000
@@ -53,6 +53,9 @@
 #include <localevent.h>
 #include <stats.h>
 
+FILE *csv_results_file_fp = NULL;
+bool csv_results_file_exists = false;
+
 /* Increase this if it does not cover at least 50% of all response
    times.  */
 #define MAX_LIFETIME	100.0		/* max. conn. lifetime in seconds */
Index: src/stat/stats.h
===================================================================
RCS file: /cvsroot/httperf/httperf/src/stat/stats.h,v
retrieving revision 1.5
diff -u -r1.5 stats.h
--- src/stat/stats.h	7 Apr 2007 06:55:33 -0000	1.5
+++ src/stat/stats.h	25 Jul 2008 18:22:47 -0000
@@ -41,4 +41,7 @@
 #define VAR(s,s2,n)	(((n) < 2) ? 0.0 : ((s2) - SQUARE(s)/(n)) / ((n) - 1))
 #define STDDEV(s,s2,n)	(((n) < 2) ? 0.0 : sqrt (VAR ((s), (s2), (n))))
 
+extern FILE *csv_results_file_fp;
+extern bool csv_results_file_exists;
+
 #endif /* stats_h */


-- 
Ted Bullock <tbullock at canada.com>
http://www.comlore.com
High Voltage Software Engineer



More information about the httperf mailing list