Permalink
Browse files

performance metrics

Added -t option to help identify performance metrics and subset coverage
  • Loading branch information...
1 parent 60aeb9a commit 3ad59172e29fd3597a139138340b43da9bbc39a3 @urbanski urbanski committed May 13, 2012
Showing with 30 additions and 3 deletions.
  1. +1 −1 pf6mod_mac.py
  2. +29 −2 pfuzz
View
@@ -3,7 +3,7 @@
import re
import sys
import os
-import urllib2
+import urllib2
MANUF_URL = "http://anonsvn.wireshark.org/wireshark/trunk/manuf"
MANUF_PATH = "/etc/manuf"
View
31 pfuzz
@@ -3,6 +3,7 @@
import sys
import re
import random
+import time
from optparse import OptionParser
#load the plugin
@@ -20,6 +21,13 @@ def call_plugin(name, *args):
plugin = load_plugin(name)
return plugin.plugin_main(*args)
+#for printing performance information
+def perf_log(value):
+ global options
+ if (options.performance_test == True):
+ print "[%f] %s" % (time.time(),value)
+
+
def h_iter(sStart, sEnd):
output = []
try:
@@ -126,6 +134,7 @@ oparser.add_option("-m", "--module", action="callback", type="string", dest="mod
oparser.add_option("-l", "--list-modules", action="store_true", dest="module_list", default=False, help="List module information")
oparser.add_option("--mac-org", action="store", dest="mac_org", default="", help="Organization to check MACs against")
oparser.add_option("-s","--sample", type="int", action="store", dest="sample_size", default=0, help="Number of IPs to sample")
+oparser.add_option("-t","--test", action="store_true", dest="performance_test", default=False, help="Print performance information")
(options, args) = oparser.parse_args()
#removed argparse functionality to support python 2.6 by default. optparse is deprecated in 2.7 so argparse code will be retained until 2.7 becomes the primary distribution
@@ -161,7 +170,9 @@ if (len(args) == 0 or args[0] == None):
#grab the prefix
+perf_log("About to parse prefixes: %s" % args[0])
prefixes = prefix_parse(args[0])
+perf_log("Prefix parse completed")
#print prefixes
#is a parser set?
@@ -184,6 +195,8 @@ for prefix in prefixes:
addrs.append(prefix)
#PERF remove duplicates
+perf_log("About to dedup addrs, which has %i members" % len(addrs))
+perf_raw_addr_count = len(addrs)
finalized_addrs = list(set(addrs))
if (options.sample_size != 0 and options.sample_size < len(finalized_addrs)):
@@ -203,6 +216,20 @@ elif (options.sample_size > len(finalized_addrs)):
sys.exit(0)
#PERF
+perf_log("About to iterate finalized_addrs, which has %i members" % len(finalized_addrs))
#output options
-for addr in finalized_addrs:
- print addr
+if (options.performance_test == True):
+ print "%i raw addresses identified by fuzzer" % perf_raw_addr_count
+ if (options.sample_size > 0):
+ print "%i addresses restricted by sampler" % options.sample_size
+ perf_total = options.sample_size
+ perf_pct = float((float(options.sample_size) / float(perf_raw_addr_count))*100)
+ else:
+ perf_total = perf_raw_addr_count
+ perc_pct = 100
+
+ print "%i total addresses printed to stdout" % perf_total
+ print "%f%% addresses represnted by sample" % perf_pct
+else:
+ for addr in finalized_addrs:
+ print addr

0 comments on commit 3ad5917

Please sign in to comment.