Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 15 Sep 2014 17:48:38 GMT
From:      dpl@FreeBSD.org
To:        svn-soc-all@FreeBSD.org
Subject:   socsvn commit: r274177 - soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw
Message-ID:  <201409151748.s8FHmcGK096711@socsvn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: dpl
Date: Mon Sep 15 17:48:38 2014
New Revision: 274177
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=274177

Log:
  Added benchmarking code

Modified:
  soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw/ip_fw_pfil.c

Modified: soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw/ip_fw_pfil.c
==============================================================================
--- soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw/ip_fw_pfil.c	Mon Sep 15 17:48:23 2014	(r274176)
+++ soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw/ip_fw_pfil.c	Mon Sep 15 17:48:38 2014	(r274177)
@@ -121,6 +121,24 @@
 SYSEND
 #endif /* SYSCTL_NODE */
 int counter = 0;
+struct timeval first, second, third, fourth;
+struct timeval dif1, dif2;
+
+#include <sys/types.h>
+#include <sys/time.h>
+void
+timediff(struct timeval *one, struct timeval *two, struct timeval *diff)
+{
+	struct timeval totalone, totaltwo;
+
+	totalone.tv_sec = one->tv_sec + one->tv_sec;
+	totalone.tv_usec = one->tv_usec + one->tv_usec;
+	totaltwo.tv_sec = two->tv_sec + two->tv_sec;
+	totaltwo.tv_usec = two->tv_usec + two->tv_usec;
+
+	diff->tv_sec = (totaltwo.tv_sec - totalone.tv_sec);
+	diff->tv_usec = (totaltwo.tv_usec - totalone.tv_usec);
+}
 
 /*
  * Handles the compilation and execution of the
@@ -141,17 +159,30 @@
 			IPFW_PF_RUNLOCK(chain);
 			return (IP_FW_PASS);	/* accept */
 		}
+
+		gettimeofday(&first, NULL);
 		ipfw_chk_jit = compile_code(args, chain);
-		ret = ipfw_chk_jit(args, chain);
+		gettimeofday(&second, NULL);
 		IPFW_PF_RUNLOCK(chain);
-	} else {
-		IPFW_PF_RLOCK(chain);
-		ret = ipfw_chk_jit(args, chain);
+	}
+
+	IPFW_PF_RLOCK(chain);
+	if (! V_ipfw_vnet_ready) { /* shutting down, leave NOW. */
 		IPFW_PF_RUNLOCK(chain);
+		return (IP_FW_PASS);	/* accept */
 	}
+	ret = ipfw_chk_jit(args, chain);
+	IPFW_PF_RUNLOCK(chain);
+
 	#include <err.h>
-	if (counter == 100)
+	if (counter == 1000){
+		gettimeofday(&third, NULL);
+		timediff(&first, &second, &dif1);
+		timediff(&second, &third, &dif2);
+		printf("Compilation time: %ld s %ld usec\n", dif1.tv_sec, dif1.tv_usec);
+		printf("Filtering time: %ld s %ld usec\n", dif2.tv_sec, dif2.tv_usec);
 		err(1, "end");
+	}
 	return (ret);
 }
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201409151748.s8FHmcGK096711>