From owner-svn-soc-all@FreeBSD.ORG Mon Sep 15 17:48:39 2014 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 260FDD2C for ; Mon, 15 Sep 2014 17:48:39 +0000 (UTC) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id EBF5878F for ; Mon, 15 Sep 2014 17:48:38 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.9/8.14.9) with ESMTP id s8FHmc0k096728 for ; Mon, 15 Sep 2014 17:48:38 GMT (envelope-from dpl@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.9/8.14.9/Submit) id s8FHmcGK096711 for svn-soc-all@FreeBSD.org; Mon, 15 Sep 2014 17:48:38 GMT (envelope-from dpl@FreeBSD.org) Date: Mon, 15 Sep 2014 17:48:38 GMT Message-Id: <201409151748.s8FHmcGK096711@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to dpl@FreeBSD.org using -f From: dpl@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r274177 - soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 15 Sep 2014 17:48:39 -0000 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 +#include +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 - 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); }