Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
get rid of sd_workstation.cpp
[simgrid.git] / teshsuite / simdag / evaluate-get-route-time / evaluate-get-route-time.c
1 /* Copyright (c) 2008-2015. The SimGrid Team.
2  * All rights reserved.                                                     */
3
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. */
6
7 //for i in $(seq 1 100); do teshsuite/simdag/platforms/evaluate_get_route_time ../examples/platforms/cluster.xml 1 2> /tmp/null ; done
8
9
10 #include <stdio.h>
11 #include "simgrid/simdag.h"
12 #include "xbt/xbt_os_time.h"
13
14 #define BILLION  1000000000L;
15
16 int main(int argc, char **argv)
17 {
18   int i, j;
19   xbt_os_timer_t timer = xbt_os_timer_new();
20
21   SD_init(&argc, argv);
22   SD_create_environment(argv[1]);
23
24   sg_host_t *hosts = sg_host_list();
25   int host_count = sg_host_count();
26
27   /* Random number initialization */
28   srand( (int) (xbt_os_time()*1000) );
29
30   do {
31     i = rand()%host_count;
32     j = rand()%host_count;
33   } while(i==j);
34
35   sg_host_t h1 = hosts[i];
36   sg_host_t h2 = hosts[j];
37   printf("%d\tand\t%d\t\t",i,j);
38   xbt_dynar_t route = xbt_dynar_new(sizeof(SD_link_t), NULL);
39
40   xbt_os_cputimer_start(timer);
41   sg_host_route(h1, h2, route);
42   xbt_os_cputimer_stop(timer);
43
44   xbt_dynar_free(&route);
45
46   printf("%f\n", xbt_os_timer_elapsed(timer) );
47
48   xbt_free(hosts);
49   SD_exit();
50
51   return 0;
52 }