Actor | Sent | Received | Send Rate | Receive Rate | Activity |
---|---|---|---|---|---|
actor1 | 30 | 44 | 15.0 msg/s | 22.0 msg/s | 74 total |
actor2 | 48 | 41 | 24.0 msg/s | 20.5 msg/s | 89 total |
actor0 | 42 | 42 | 21.0 msg/s | 21.0 msg/s | 84 total |
actor3 | 60 | 39 | 30.0 msg/s | 19.5 msg/s | 99 total |
actor4 | 60 | 39 | 30.0 msg/s | 19.5 msg/s | 99 total |
actor5 | 24 | 45 | 12.0 msg/s | 22.5 msg/s | 69 total |
actor6 | 30 | 44 | 15.0 msg/s | 22.0 msg/s | 74 total |
This is the Elixir code that defines the actor simulation model:
# Create 7 actors that all know each other, sending random :hi messages
# Fixed random seed for reproducible results
:rand.seed(:exs1024, {42, 123, 456})
# Generate random delays for each actor (100-500ms)
random_delays = Enum.map(1..7, fn _ -> :rand.uniform(400) + 100 end)
# All actors know each other (full mesh topology)
all_targets = [:actor0, :actor1, :actor2, :actor3, :actor4, :actor5, :actor6]
simulation =
ActorSimulation.new()
|> ActorSimulation.add_actor(:actor0,
send_pattern: {:periodic, Enum.at(random_delays, 0), :hi},
targets: all_targets -- [:actor0]
)
|> ActorSimulation.add_actor(:actor1,
send_pattern: {:periodic, Enum.at(random_delays, 1), :hi},
targets: all_targets -- [:actor1]
)
|> ActorSimulation.add_actor(:actor2,
send_pattern: {:periodic, Enum.at(random_delays, 2), :hi},
targets: all_targets -- [:actor2]
)
|> ActorSimulation.add_actor(:actor3,
send_pattern: {:periodic, Enum.at(random_delays, 3), :hi},
targets: all_targets -- [:actor3]
)
|> ActorSimulation.add_actor(:actor4,
send_pattern: {:periodic, Enum.at(random_delays, 4), :hi},
targets: all_targets -- [:actor4]
)
|> ActorSimulation.add_actor(:actor5,
send_pattern: {:periodic, Enum.at(random_delays, 5), :hi},
targets: all_targets -- [:actor5]
)
|> ActorSimulation.add_actor(:actor6,
send_pattern: {:periodic, Enum.at(random_delays, 6), :hi},
targets: all_targets -- [:actor6]
)
|> ActorSimulation.run(duration: 2000)
# Generate the report
html = MermaidReportGenerator.generate_report(simulation,
title: "Random Messaging Network",
layout: "TB",
model_source: model_source
)