Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Cosmetics
[simgrid.git] / testsuite / surf / trace_usage.c
1 /* A few tests for the trace library                                       */
2
3 /* Authors: Arnaud Legrand                                                  */
4
5 /* This program is free software; you can redistribute it and/or modify it
6    under the terms of the license (GNU LGPL) which comes with this package. */
7
8 #include <stdlib.h>
9 #include <stdio.h>
10 #include <string.h>
11 #include "surf/trace_mgr.h"
12
13 void test(void);
14 void test(void)
15 {
16   tmgr_history_t history = tmgr_history_new();
17   tmgr_trace_t trace_A = tmgr_trace_new("trace_A.txt");
18   tmgr_trace_t trace_B = tmgr_trace_new("trace_B.txt");
19   xbt_heap_float_t next_event_date = -1.0;
20   xbt_maxmin_float_t value = -1.0;
21   char *resource = NULL;
22   char *host_A = strdup("Host A");
23   char *host_B = strdup("Host B");
24
25   tmgr_history_add_trace(history, trace_A, 1.0, 2, host_A);
26   tmgr_history_add_trace(history, trace_B, 0.0, 0, host_B);
27
28   while ((next_event_date = tmgr_history_next_date(history)) != -1.0) {
29     printf(XBT_HEAP_FLOAT_T " : \n", next_event_date);
30     while (tmgr_history_get_next_event_leq(history, next_event_date,
31                                            &value, (void **) &resource)) {
32       printf("\t %s : " XBT_MAXMIN_FLOAT_T "\n", resource, value);
33     }
34     if (next_event_date > 1000)
35       break;
36   }
37
38   tmgr_trace_free(trace_A);
39   tmgr_trace_free(trace_B);
40   tmgr_history_free(history);
41   free(host_B);
42   free(host_A);
43 }
44
45
46 int main(int argc, char **argv)
47 {
48   test();
49   return 0;
50 }