Commit 8adc1d83 authored by Ad Schellevis's avatar Ad Schellevis

(netflow, flowd aggregate) add profile support, replace deepcopy for cheaper copy

parent 8872e1c7
......@@ -74,7 +74,7 @@ def aggregate_flowd(do_vacuum=False):
for stream_agg_object in stream_agg_objects:
# class add() may change the flow contents for processing, its better to isolate
# paremeters here.
flow_record_cpy = copy.deepcopy(flow_record)
flow_record_cpy = copy.copy(flow_record)
stream_agg_object.add(flow_record_cpy)
prev_recv = flow_record['recv']
......@@ -164,7 +164,23 @@ class Main(object):
if len(sys.argv) > 1 and 'console' in sys.argv[1:]:
# command line start
Main()
if 'profile' in sys.argv[1:]:
# start with profiling
import cProfile
import StringIO
import pstats
pr = cProfile.Profile(builtins=False)
pr.enable()
Main()
pr.disable()
s = StringIO.StringIO()
sortby = 'cumulative'
ps = pstats.Stats(pr, stream=s).sort_stats(sortby)
ps.print_stats()
print s.getvalue()
else:
Main()
else:
# Daemonize flowd aggregator
daemon = Daemonize(app="flowd_aggregate", pid='/var/run/flowd_aggregate.pid', action=Main)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment