1 /* Copyright (c) 2008-2023. The SimGrid Team.
2 * All rights reserved. */
4 /* This program is free software; you can redistribute it and/or modify it
5 * under the terms of the license (GNU LGPL) which comes with this package. */
8 for i in $(seq 1 20); do
9 teshsuite/s4u/evaluate-get-route-time/evaluate-get-route-time examples/platforms/cluster_backbone.xml
14 #include "simgrid/s4u.hpp"
15 #include "xbt/random.hpp"
16 #include "xbt/xbt_os_time.h"
19 int main(int argc, char** argv)
21 xbt_os_timer_t timer = xbt_os_timer_new();
23 simgrid::s4u::Engine e(&argc, argv);
24 e.load_platform(argv[1]);
27 std::vector<simgrid::s4u::Host*> hosts = e.get_all_hosts();
28 int host_count = static_cast<int>(e.get_host_count());
30 /* Random number initialization */
31 simgrid::xbt::random::set_mersenne_seed(static_cast<int>(xbt_os_time()));
33 /* Take random i and j, with i != j */
34 xbt_assert(host_count > 1);
35 int i = simgrid::xbt::random::uniform_int(0, host_count - 1);
36 int j = simgrid::xbt::random::uniform_int(0, host_count - 2);
37 if (j >= i) // '>=' is not a bug: j is uniform on host_count-1 values, and shifted on need to maintain uniform random
40 printf("%d\tand\t%d\t\t", i, j);
42 std::vector<simgrid::s4u::Link*> route;
44 xbt_os_cputimer_start(timer);
45 hosts[i]->route_to(hosts[j], route, nullptr);
46 xbt_os_cputimer_stop(timer);
48 printf("%f\n", xbt_os_timer_elapsed(timer));