Revision: 14702
Author: adrian.chadd
Date: Thu May 27 05:22:23 2010
Log: This benchmark tool doesn't currently belong here but it's convienent.
http://code.google.com/p/lusca-cache/source/detail?r=14702
Added:
/branches/LUSCA_HEAD/test-suite/atf/url_benchmark.c
Modified:
/branches/LUSCA_HEAD/test-suite/atf/Makefile
=======================================
--- /dev/null
+++ /branches/LUSCA_HEAD/test-suite/atf/url_benchmark.c Thu May 27 05:22:23
2010
@@ -0,0 +1,94 @@
+#include "include/config.h"
+
+#include <atf-c.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <math.h>
+#include <fcntl.h>
+#include <sys/errno.h>
+#include <sys/socket.h>
+#include <sys/time.h>
+#include <netinet/in.h>
+
+#include "include/util.h"
+
+#include "libsqurl/defines.h"
+#include "libsqurl/domain.h"
+#include "libsqurl/proto.h"
+#include "libsqurl/url.h"
+
+/*
+ * This is designed to do some very, very basic benchmarking
+ * of the URL assembly code.
+ */
+
+typedef int URLFUNC(char *, protocol_t, const char *, const char *, int,
const char *, int urlpath_len);
+
+long
+do_benchmark(int nloop, URLFUNC *f, protocol_t proto, const char *login,
const char *host, int port, const char *urlpath)
+{
+ int urlpath_len;
+ char urlbuf[MAX_URL];
+ int i;
+ struct timeval ts, te;
+ long sd, ud;
+
+ urlpath_len = strlen(urlpath);
+
+ gettimeofday(&ts, NULL);
+ for (i = 0; i < nloop; i++) {
+ urlbuf[0] = '\0';
+ (void) f(urlbuf, proto, login, host, port, urlpath,
urlpath_len);
+ }
+ gettimeofday(&te, NULL);
+
+ sd = te.tv_sec - ts.tv_sec;
+ ud = te.tv_usec - ts.tv_usec;
+ if (sd > 0)
+ ud = ud + (sd * 1000000);
+
+ return ud;
+}
+
+void
+do_run(int iloop, int nloop, const char *tag, URLFUNC *f, protocol_t
proto, const char *login, const char *host, int port, const char *urlpath)
+{
+ int i;
+ long l;
+
+ for (i = 0; i < iloop; i++) {
+ l = do_benchmark(nloop, f, proto, login, host, port, urlpath);
+ printf("Run %d: %s: %ld msec; %.3f usec per request\n", i, tag, l /
1000, (float) l / (float) nloop);
+ }
+
+}
+
+int
+main(int argc, const char *argv[])
+{
+ int i;
+
+ do_run(10, 100000, "old", urlMakeHttpCanonical, PROTO_HTTP,
+ "", "www.creative.net.au", 80, "/test.html");
+ do_run(10, 100000, "new", urlMakeHttpCanonical2, PROTO_HTTP,
+ "", "www.creative.net.au", 80, "/test.html");
+
+ do_run(10, 100000, "old, port 81", urlMakeHttpCanonical, PROTO_HTTP,
+ "", "www.creative.net.au", 81, "/test.html");
+ do_run(10, 100000, "new, port 81", urlMakeHttpCanonical2, PROTO_HTTP,
+ "", "www.creative.net.au", 81, "/test.html");
+
+ do_run(10, 100000, "old, port 80, login", urlMakeHttpCanonical,
PROTO_HTTP,
+ "username", "www.creative.net.au", 80, "/test.html");
+ do_run(10, 100000, "new, port 80, login", urlMakeHttpCanonical2,
PROTO_HTTP,
+ "username", "www.creative.net.au", 80, "/test.html");
+
+ do_run(10, 100000, "old, port 81, login", urlMakeHttpCanonical,
PROTO_HTTP,
+ "username", "www.creative.net.au", 81, "/test.html");
+ do_run(10, 100000, "new, port 81, login", urlMakeHttpCanonical2,
PROTO_HTTP,
+ "username", "www.creative.net.au", 81, "/test.html");
+}
+
=======================================
--- /branches/LUSCA_HEAD/test-suite/atf/Makefile Sun May 23 05:33:32 2010
+++ /branches/LUSCA_HEAD/test-suite/atf/Makefile Thu May 27 05:22:23 2010
@@ -48,7 +48,7 @@
LDFLAGS=$(LDADD) -L$(ATF_LIBDIR)
CFLAGS=-O -g -I$(BASEDIR) -I$(ATF_INCLUDEDIR)
-all: libhttp lib_Vector libsqurl
+all: libhttp lib_Vector libsqurl url_benchmark
libhttp: libhttp.o core.o
$(CC) core.o libhttp.o -o libhttp $(LDFLAGS)
@@ -59,9 +59,12 @@
libsqurl: libsqurl.o core.o
$(CC) core.o libsqurl.o -o libsqurl $(LDFLAGS)
+url_benchmark: url_benchmark.o core.o
+ $(CC) core.o url_benchmark.o -o url_benchmark $(LDFLAGS)
+
check: libhttp lib_Vector libsqurl
@env PATH=$$PATH:$(ATF_BINDIR) $(ATF_BINDIR)/atf-run |
$(ATF_BINDIR)/atf-report
clean:
- rm -f libhttp lib_Vector libsqurl *.o
-
+ rm -f libhttp lib_Vector libsqurl url_benchmark *.o
+
--
You received this message because you are subscribed to the Google Groups
"lusca-commit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/lusca-commit?hl=en.