benchmark also with ascii tracing
authorGustavo J. A. M. Carneiro <gjc@inescporto.pt>
Thu, 16 Jul 2009 14:58:57 +0100
changeset 4011 2718d6239875
parent 4010 4e22072bdc58
child 4012 83c9f4ea249d
benchmark also with ascii tracing
utils/flowmon/bench-all.py
utils/flowmon/flowmon-bench.py
--- a/utils/flowmon/bench-all.py	Thu Jul 16 14:39:29 2009 +0100
+++ b/utils/flowmon/bench-all.py	Thu Jul 16 14:58:57 2009 +0100
@@ -6,6 +6,7 @@
 import re
 import tempfile
 import os
+import atexit
 
 DATA_LIMIT = None
 CPU_LIMIT = None
@@ -110,12 +111,16 @@
                                     options.num_nodes_side_max + options.num_nodes_side_step,
                                     options.num_nodes_side_step):
             for run_number in range(options.num_runs):
-                for enable_monitor in [False, True]:
+                for enable_monitor, enable_trace in [(False, False), (False, True), (True, False)]:
                     args = ["--NumNodesSide=%i" % num_nodes_side,
                             "--RunNumber=%i" % run_number,
                             "--EnableMonitor=%i" % enable_monitor,
                             "--StopTime=%f" % options.stop_time,
                             ]
+                    if enable_trace:
+                        trace_fname = tempfile.mktemp(prefix='bench-trace', suffix='.tr')
+                        args.append("--EnableAsciiTrace=%s" % trace_fname)
+                        atexit.register(os.unlink, trace_fname)
                     try:
                         max_mem, duration, results_fname = run_sim(args)
                     except RuntimeError, ex:
--- a/utils/flowmon/flowmon-bench.py	Thu Jul 16 14:39:29 2009 +0100
+++ b/utils/flowmon/flowmon-bench.py	Thu Jul 16 14:58:57 2009 +0100
@@ -33,8 +33,8 @@
     cmd.NumNodesSide = None
     cmd.AddValue("NumNodesSide", "Grid side number of nodes (total number of nodes will be this number squared)")
     cmd.AddValue("EnableMonitor", "Set to 0 or 1 to disable/enable flow monitoring")
-    cmd.AddValue("EnableAsciiTrace", "Set to 0 or 1 to disable/enable ascii trace file")
-    cmd.EnableAsciiTrace = '0'
+    cmd.AddValue("EnableAsciiTrace", "Enable ascii trace, with given file name in this parameter")
+    cmd.EnableAsciiTrace = None
     cmd.AddValue("RunNumber", "Run number (statistics)")
     cmd.AddValue("Results", "Write results to the given file")
     cmd.AddValue("StopTime", "Simulation stop time")
@@ -44,7 +44,6 @@
 
 
     enable_monitor = int(cmd.EnableMonitor)
-    enable_ascii_trace = int(cmd.EnableAsciiTrace)
     run_number = int(cmd.RunNumber)
     if cmd.NumNodesSide is None:
         num_nodes_side = NUM_NODES_SIDE
@@ -134,9 +133,9 @@
             #app = onOffHelper.Install(ns3.NodeContainer(nodes[yi][xi+flow_hops]))
             #app.Start(ns3.Seconds(start_time_rng.GetValue()))
 
-    if enable_ascii_trace:
+    if cmd.EnableAsciiTrace is not None:
         print "Configure Tracing."
-        ascii = ns3.ofstream("flowmon-bench.tr")
+        ascii = ns3.ofstream(cmd.EnableAsciiTrace)
         ns3.PointToPointHelper.EnableAsciiAll(ascii)
 
 
@@ -185,7 +184,7 @@
         else:
             print_stats(sys.stdout, monitor, classifier)
 
-    if enable_ascii_trace:
+    if cmd.EnableAsciiTrace is not None:
         ascii.close()
 
     return 0