Explorar el Código

adapted CLI to support selecting DCP implementations

Snej69420 hace 8 meses
padre
commit
7d0609e8ac
Se han modificado 2 ficheros con 11 adiciones y 6 borrados
  1. 5 4
      benchmarks/pythonpdevs/main.py
  2. 6 2
      benchmarks/testPyPDEVS.py

+ 5 - 4
benchmarks/pythonpdevs/main.py

@@ -57,6 +57,7 @@ def parse_args():
     parser.add_argument('-D', '--dynamic', action="store_true", default=False, help='Enables Dynamic Structure DEVS')
     parser.add_argument('-n', '--number', required=False, default=1, type=int, help='Number of models to be generated within a cycle in a single coupled model')
     parser.add_argument("-g", "--gen-mode", choices=GEN_METHODS, help="Determines the spread of model creation.")
+    parser.add_argument("--DCP", choices=["old", "memoised"], default="", help="Select the DCP implementation, old: legacy, memoised: cached, and leave empty to use the default one.")
     args = parser.parse_args()
 
     if args.model_type not in MODEL_TYPES:
@@ -107,18 +108,18 @@ if __name__ == '__main__':
 
     # devstone_model.dot(f"{args.model_type}-before")
 
-    import cProfile
-    import pstats
-    import io
+    # import cProfile
+    # import pstats
+    # import io
 
     sim = Simulator(env)
+    sim.setRoutingMode(args.DCP)
     # sim.setVerbose(None)
 
     if args.classic:
         sim.setClassicDEVS(True)
     if args.dynamic:
         sim.setDSDEVS(True)
-
     # adds massive overhead
     # sim.setTerminationCondition(term)
     # sim.setTerminationTime(10.0)

+ 6 - 2
benchmarks/testPyPDEVS.py

@@ -36,7 +36,7 @@ def create_graph(file, title=None):
 
     subprocess.run(cmd, shell=True)
 
-def run_devstone(model_type, depth, width, mode, out, memory, stats, *, classic=False, number=1, gen_mode="uniform"):
+def run_devstone(model_type, depth, width, mode, out, memory, stats, DCP, *, classic=False, number=1, gen_mode="uniform"):
     """Runs the devstone_driver.py script and returns timing results as floats."""
     SCRIPT_PATH = PyPDEVS
     if mode == "minimal":
@@ -50,6 +50,9 @@ def run_devstone(model_type, depth, width, mode, out, memory, stats, *, classic=
         "-i", str(INT_CYCLES),
         "-e", str(EXT_CYCLES),
     ]
+    if DCP:
+        cmd.extend(["--DCP", DCP])
+
     if stats:
         cmd.extend(["-s"])
 
@@ -112,6 +115,7 @@ def defaultArguments(parser):
     parser.add_argument("-M", "--memory", action="store_true", help="Measures the memory usage of a simulation.")
     parser.add_argument("-i", "--interval", default=1.0, type=float, help="The interval at which measurements are taken.")
     parser.add_argument("--stats", "-s", action="store_true", help="Enable Event Tracking")
+    parser.add_argument("--DCP", choices=["old", "memoised"], default="", help="Select the DCP implementation, old: legacy, memoised: cached, and leave empty to use the default one.")
 
 def Minimal(subparsers):
     minimal = subparsers.add_parser("minimal", help="Minimal DEVS kernel")
@@ -200,7 +204,7 @@ def run(writer, csvfile, model_type, d, w, args, mem_cmd, extra):
                 creation, setup, sim = run_devstone(
                     model_type, depth, width,
                     args.mode, args.output,
-                    mem_cmd, args.stats,
+                    mem_cmd, args.stats, args.DCP,
                     **extra
                 )