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

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     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/. */
     7 #ifndef timecard_h__
     8 #define timecard_h__
    10 #include <stdlib.h>
    11 #include "prtime.h"
    13 #ifdef __cplusplus
    14 extern "C" {
    15 #endif
    17 #define STAMP_TIMECARD(card,event)                                       \
    18   do {                                                                   \
    19     if (card) {                                                          \
    20       stamp_timecard((card), (event), __FILE__, __LINE__, __FUNCTION__); \
    21     }                                                                    \
    22   } while (0)
    24 #define TIMECARD_INITIAL_TABLE_SIZE 16
    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  */
    31 typedef struct {
    32   PRTime timestamp;
    33   const char *event;
    34   const char *file;
    35   unsigned int line;
    36   const char *function;
    37 } TimecardEntry;
    39 typedef struct Timecard {
    40   size_t curr_entry;
    41   size_t entries_allocated;
    42   TimecardEntry *entries;
    43   PRTime start_time;
    44 } Timecard;
    46 /**
    47  * Creates a new Timecard structure for tracking events.
    48  */
    49 Timecard *
    50 create_timecard();
    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);
    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);
    71 /**
    72  * Formats and outputs the contents of a timecard onto stdout.
    73  */
    74 void
    75 print_timecard(Timecard *tc);
    77 #ifdef __cplusplus
    78 }
    79 #endif
    81 #endif

mercurial