|
|
@@ -59,6 +59,9 @@ function parse_commandline()
|
|
|
"--stats", "-s"
|
|
|
help = "Enable Event Tracking"
|
|
|
action = :store_true
|
|
|
+ "--profile", "-P"
|
|
|
+ help = "Runs the simulation with a simple Profiler"
|
|
|
+ action = :store_true
|
|
|
"--logging", "-L"
|
|
|
help = "Enables and print model traces to the console"
|
|
|
action = :store_true
|
|
|
@@ -72,7 +75,7 @@ function parse_commandline()
|
|
|
end
|
|
|
|
|
|
# --- Single Simulation Runner ---
|
|
|
-function run_single_simulation(topology_type::Structure, type_str::String, depth::Int, width::Int, stats::Bool, logging::Bool)
|
|
|
+function run_single_simulation(topology_type::Structure, type_str::String, depth::Int, width::Int, stats::Bool, logging::Bool, profile::Bool)
|
|
|
int_delay = 0.0
|
|
|
ext_delay = 0.0
|
|
|
|
|
|
@@ -84,19 +87,17 @@ function run_single_simulation(topology_type::Structure, type_str::String, depth
|
|
|
|
|
|
# Setup
|
|
|
AgentUnion = Union{DelayedAtomic, Generator}
|
|
|
- model = compile_devs(env, AgentUnion, (UniversalEvent, ); logging)
|
|
|
+ model = compile_devs(env, AgentUnion, (UniversalEvent, ); logging=false)
|
|
|
engine_setup_time = time()
|
|
|
|
|
|
-# simulate_devs!(warmup)
|
|
|
-# model = compile_devs(env, AgentUnion, (UniversalEvent, ); logging=false)
|
|
|
-
|
|
|
-# Profile.clear()
|
|
|
-
|
|
|
- # Simulate
|
|
|
- simulate_devs!(model)
|
|
|
-# @profile simulate_devs!(model)
|
|
|
+ if profile
|
|
|
+# Profile.clear()
|
|
|
+ @time simulate_devs!(model)
|
|
|
+# Profile.print(format=:flat, sortedby=:count)
|
|
|
+ else
|
|
|
+ simulate_devs!(model)
|
|
|
+ end
|
|
|
sim_time = time()
|
|
|
-# Profile.print(format=:flat, sortedby=:count)
|
|
|
|
|
|
t_creation = model_created_time - start_time
|
|
|
t_setup = engine_setup_time - model_created_time
|
|
|
@@ -110,6 +111,7 @@ function main()
|
|
|
args = parse_commandline()
|
|
|
stats = args["stats"]
|
|
|
logging = args["logging"]
|
|
|
+ profile = args["profile"]
|
|
|
|
|
|
# Process step sizes
|
|
|
ds = args["depth-stepsize"] > 0 ? args["depth-stepsize"] : args["max-depth"]
|
|
|
@@ -138,7 +140,7 @@ function main()
|
|
|
open(file_path, file_mode) do file
|
|
|
# Write Header if new file
|
|
|
if !args["append"] || filesize(file_path) == 0
|
|
|
- write(file, "model_type,depth,width,run,creation_time,setup_time,simulation_time\n")
|
|
|
+ write(file, "simulator,model_type,depth,width,run,creation_time,setup_time,simulation_time\n")
|
|
|
end
|
|
|
|
|
|
# Grid Search Loop
|
|
|
@@ -152,14 +154,14 @@ function main()
|
|
|
|
|
|
# WARM-UP PASS (Only for the very first execution of the script to compile)
|
|
|
if run == 0 && depth == ds && width == ws && repetitions != 1
|
|
|
- run_single_simulation(topology_type, model_str, 2, 2, false, false)
|
|
|
+ run_single_simulation(topology_type, model_str, 2, 2, false, false, false)
|
|
|
end
|
|
|
|
|
|
# Actual measured run
|
|
|
- t_creation, t_setup, t_sim, model = run_single_simulation(topology_type, model_str, depth, width, stats, logging)
|
|
|
+ t_creation, t_setup, t_sim, model = run_single_simulation(topology_type, model_str, depth, width, stats, logging, profile)
|
|
|
|
|
|
# Log to CSV
|
|
|
- write(file, "$model_str,$depth,$width,$run,$t_creation,$t_setup,$t_sim\n")
|
|
|
+ write(file, "agents,$model_str,$depth,$width,$run,$t_creation,$t_setup,$t_sim\n")
|
|
|
|
|
|
if args["output"] || args["stats"]
|
|
|
println(" Creation: $(round(t_creation, digits=4))s | Setup: $(round(t_setup, digits=4))s | Sim: $(round(t_sim, digits=4))s")
|