media/webrtc/signaling/src/common/time_profiling/timecard.h

branch
TOR_BUG_9701
changeset 10
ac0c01689b40
equal deleted inserted replaced
-1:000000000000 0:f945ffd4b2a9
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6
7 #ifndef timecard_h__
8 #define timecard_h__
9
10 #include <stdlib.h>
11 #include "prtime.h"
12
13 #ifdef __cplusplus
14 extern "C" {
15 #endif
16
17 #define STAMP_TIMECARD(card,event) \
18 do { \
19 if (card) { \
20 stamp_timecard((card), (event), __FILE__, __LINE__, __FUNCTION__); \
21 } \
22 } while (0)
23
24 #define TIMECARD_INITIAL_TABLE_SIZE 16
25
26 /*
27 * The "const char *" members of this structure point to static strings.
28 * We do not own them, and should not attempt to deallocate them.
29 */
30
31 typedef struct {
32 PRTime timestamp;
33 const char *event;
34 const char *file;
35 unsigned int line;
36 const char *function;
37 } TimecardEntry;
38
39 typedef struct Timecard {
40 size_t curr_entry;
41 size_t entries_allocated;
42 TimecardEntry *entries;
43 PRTime start_time;
44 } Timecard;
45
46 /**
47 * Creates a new Timecard structure for tracking events.
48 */
49 Timecard *
50 create_timecard();
51
52 /**
53 * Frees the memory associated with a timecard. After returning, the
54 * timecard pointed to by tc is no longer valid.
55 */
56 void
57 destroy_timecard(Timecard *tc);
58
59 /**
60 * Records a new event in the indicated timecard. This should not be
61 * called directly; code should instead use the STAMP_TIMECARD macro,
62 * above.
63 */
64 void
65 stamp_timecard(Timecard *tc,
66 const char *event,
67 const char *file,
68 unsigned int line,
69 const char *function);
70
71 /**
72 * Formats and outputs the contents of a timecard onto stdout.
73 */
74 void
75 print_timecard(Timecard *tc);
76
77 #ifdef __cplusplus
78 }
79 #endif
80
81 #endif

mercurial