Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
3340d38b2b36a3ff6042033c552d53805f44a2c8
[simgrid.git] / teshsuite / simdag / platforms / Evaluate_parse_time.c
1 /* Copyright (c) 2008, 2009, 2010. 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 //teshsuite/simdag/platforms/evaluate_parse_time ../examples/platforms/nancy.xml
8
9 #include <stdio.h>
10 #include <stdlib.h>
11 #include "simdag/simdag.h"
12 #include "surf/surf_private.h"
13 #include <time.h>
14
15 #define BILLION  1000000000L;
16 extern routing_global_t global_routing;
17
18 int main(int argc, char **argv)
19 {
20         struct timespec start, stop;
21         double accum;
22
23         /* initialisation of SD */
24         SD_init(&argc, argv);
25
26 #if _POSIX_TIMERS > 0
27         if( clock_gettime( CLOCK_REALTIME, &start) == -1 ) {
28         perror( "clock gettime" );
29         return EXIT_FAILURE;
30         }
31 #else
32       struct timeval tv;
33       gettimeofday(&tv, NULL);
34       start.tv_sec = tv.tv_sec;
35       start.tv_nsec = tv.tv_usec*1000;
36 #endif
37         /* creation of the environment */
38         SD_create_environment(argv[1]);
39
40 #if _POSIX_TIMERS > 0
41         if( clock_gettime( CLOCK_REALTIME, &stop) == -1 ) {
42         perror( "clock gettime" );
43         return EXIT_FAILURE;
44         }
45 #else
46       gettimeofday(&tv, NULL);
47       stop.tv_sec = tv.tv_sec;
48       stop.tv_nsec = tv.tv_usec*1000;
49 #endif
50
51         accum = ( stop.tv_sec - start.tv_sec )
52                    + (double)( stop.tv_nsec - start.tv_nsec )
53                          / (double)BILLION;
54
55         printf( "%lf\n", accum );
56
57         sleep(20);
58
59         SD_exit();
60
61         return 0;
62 }