Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
source file of trace usage test case
[simgrid.git] / win32_testsuite / borland / builder6 / simulation / surf / trace_usage / trace_usage.c
1 //---------------------------------------------------------------------------
2
3 #pragma hdrstop
4
5 //---------------------------------------------------------------------------
6
7 #include <stdlib.h>
8 #include <stdio.h>
9 #include <string.h>
10 #include "surf/trace_mgr.h"
11 #include "surf/surf.h"
12
13 #include "xbt/log.h"
14 XBT_LOG_NEW_DEFAULT_CATEGORY(surf_test,"Messages specific for surf example");
15
16 void test(void);
17 void test(void)
18 {
19                 tmgr_history_t history = tmgr_history_new();
20                 tmgr_trace_t trace_A = tmgr_trace_new("trace_A.txt");
21                 tmgr_trace_t trace_B = tmgr_trace_new("trace_B.txt");
22                 double next_event_date = -1.0;
23                 double value = -1.0;
24                 char *resource = NULL;
25                 char *host_A = strdup("Host A");
26                 char *host_B = strdup("Host B");
27                 
28                 tmgr_history_add_trace(history, trace_A, 1.0, 2, host_A);
29                 tmgr_history_add_trace(history, trace_B, 0.0, 0, host_B);
30                 
31                 while ((next_event_date = tmgr_history_next_date(history)) != -1.0) 
32                 {
33                         DEBUG1("%g" " : \n", next_event_date);
34                         while (tmgr_history_get_next_event_leq(history, next_event_date,&value, (void **) &resource)) {
35                         DEBUG2("\t %s : " "%g" "\n", resource, value);
36                 }
37                 
38                 if (next_event_date > 1000)
39                         break;
40         }
41                 
42         tmgr_history_free(history);
43         free(host_B);
44         free(host_A);
45 }
46
47
48 #pragma argsused
49 int main(int argc, char* argv[])
50 {
51         surf_init(&argc,argv);
52         test();
53         surf_exit();
54
55         return 0;
56 }
57 //---------------------------------------------------------------------------