Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge pull request #2 from mquinson/master
[simgrid.git] / teshsuite / simdag / platforms / 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 <stdlib.h>
12 #include "simgrid/simdag.h"
13 #include "surf/surf.h"
14 #include "xbt/xbt_os_time.h"
15
16 #define BILLION  1000000000L;
17
18 int main(int argc, char **argv)
19 {
20   int i, j;
21   xbt_os_timer_t timer = xbt_os_timer_new();
22
23   SD_init(&argc, argv);
24   SD_create_environment(argv[1]);
25
26   sg_host_t *hosts = sg_host_list();
27   int host_count = sg_host_count();
28
29   /* Random number initialization */
30   srand( (int) (xbt_os_time()*1000) );
31
32   do {
33     i = rand()%host_count;
34     j = rand()%host_count;
35   } while(i==j);
36
37   sg_host_t h1 = hosts[i];
38   sg_host_t h2 = hosts[j];
39   printf("%d\tand\t%d\t\t",i,j);
40
41   xbt_os_cputimer_start(timer);
42   SD_route_get_list(h1, h2);
43   xbt_os_cputimer_stop(timer);
44
45   printf("%f\n", xbt_os_timer_elapsed(timer) );
46
47   xbt_free(hosts);
48   SD_exit();
49
50   return 0;
51 }