Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
size_t instead of unsigned long for storage size and used_size
[simgrid.git] / testsuite / surf / trace_usage.c
1 /* A few tests for the trace library                                       */
2
3 /* Copyright (c) 2004, 2005, 2006, 2009, 2010. The SimGrid Team.
4  * All rights reserved.                                                     */
5
6 /* This program is free software; you can redistribute it and/or modify it
7  * under the terms of the license (GNU LGPL) which comes with this package. */
8 #ifdef __BORLANDC__
9 #pragma hdrstop
10 #endif
11
12 #include "surf/trace_mgr.h"
13 #include "surf/surf.h"
14
15 #include "xbt/log.h"
16
17 #include <stdlib.h>
18 #include <stdio.h>
19 #include <string.h>
20
21 XBT_LOG_NEW_DEFAULT_CATEGORY(surf_test,
22                              "Messages specific for surf example");
23
24 void test(void);
25 void test(void)
26 {
27   tmgr_history_t history = tmgr_history_new();
28   tmgr_trace_t trace_A = tmgr_trace_new_from_file("trace_A.txt");
29   tmgr_trace_t trace_B = tmgr_trace_new_from_file("trace_B.txt");
30   double next_event_date = -1.0;
31   double value = -1.0;
32   char *resource = NULL;
33   char *host_A = strdup("Host A");
34   char *host_B = strdup("Host B");
35
36   tmgr_history_add_trace(history, trace_A, 1.0, 2, host_A);
37   tmgr_history_add_trace(history, trace_B, 0.0, 0, host_B);
38
39   while ((next_event_date = tmgr_history_next_date(history)) != -1.0) {
40     XBT_DEBUG("%g" " : \n", next_event_date);
41     while (tmgr_history_get_next_event_leq(history, next_event_date,
42                                            &value, (void **) &resource)) {
43       XBT_DEBUG("\t %s : " "%g" "\n", resource, value);
44     }
45     if (next_event_date > 1000)
46       break;
47   }
48
49   tmgr_history_free(history);
50   free(host_B);
51   free(host_A);
52 }
53
54 #ifdef __BORLANDC__
55 #pragma argsused
56 #endif
57
58
59 int main(int argc, char **argv)
60 {
61   surf_init(&argc, argv);
62   test();
63   surf_exit();
64   return 0;
65 }