(root)/
bison-3.8.2/
lib/
timevar.h
       1  /* Timing variables for measuring application performance.
       2  
       3     Copyright (C) 2000, 2002, 2004, 2009-2015, 2018-2021 Free Software
       4     Foundation, Inc.
       5  
       6     Contributed by Alex Samuel <samuel@codesourcery.com>
       7  
       8     This program is free software: you can redistribute it and/or modify
       9     it under the terms of the GNU General Public License as published by
      10     the Free Software Foundation, either version 3 of the License, or
      11     (at your option) any later version.
      12  
      13     This program is distributed in the hope that it will be useful,
      14     but WITHOUT ANY WARRANTY; without even the implied warranty of
      15     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      16     GNU General Public License for more details.
      17  
      18     You should have received a copy of the GNU General Public License
      19     along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
      20  
      21  #ifndef _TIMEVAR_H
      22  # define _TIMEVAR_H 1
      23  
      24  # include <stdio.h>
      25  
      26  # include "xtime.h"
      27  
      28  # ifdef  __cplusplus
      29  extern "C" {
      30  # endif
      31  
      32  /* Timing variables are used to measure elapsed time in various
      33     portions of the application.  Each measures elapsed user, system, and
      34     wall-clock time, as appropriate to and supported by the host
      35     system.
      36  
      37     Timing variables are defined using the DEFTIMEVAR macro in
      38     timevar.def.  Each has an enumeral identifier, used when referring
      39     to the timing variable in code, and a character string name.
      40  
      41     Timing variables can be used in two ways:
      42  
      43       - On the timing stack, using timevar_push and timevar_pop.
      44         Timing variables may be pushed onto the stack; elapsed time is
      45         attributed to the topmost timing variable on the stack.  When
      46         another variable is pushed on, the previous topmost variable is
      47         'paused' until the pushed variable is popped back off.
      48  
      49       - As a standalone timer, using timevar_start and timevar_stop.
      50         All time elapsed between the two calls is attributed to the
      51         variable.
      52  */
      53  
      54  /* This structure stores the various varieties of time that can be
      55     measured.  Times are stored in seconds.  The time may be an
      56     absolute time or a time difference; in the former case, the time
      57     base is undefined, except that the difference between two times
      58     produces a valid time difference.  */
      59  
      60  struct timevar_time_def
      61  {
      62    /* User time in this process.  */
      63    xtime_t user;
      64  
      65    /* System time (if applicable for this host platform) in this
      66       process.  */
      67    xtime_t sys;
      68  
      69    /* Wall clock time.  */
      70    xtime_t wall;
      71  };
      72  
      73  /* An enumeration of timing variable identifiers.  Constructed from
      74     the contents of timevar.def.  */
      75  
      76  #define DEFTIMEVAR(identifier__, name__) \
      77      identifier__,
      78  typedef enum
      79  {
      80  #include "timevar.def"
      81    TIMEVAR_LAST
      82  }
      83  timevar_id_t;
      84  #undef DEFTIMEVAR
      85  
      86  /* Initialize timing variables.  */
      87  
      88  void timevar_init (void);
      89  
      90  /* Push TIMEVAR onto the timing stack.  No further elapsed time is
      91     attributed to the previous topmost timing variable on the stack;
      92     subsequent elapsed time is attributed to TIMEVAR, until it is
      93     popped or another element is pushed on top.
      94  
      95     TIMEVAR cannot be running as a standalone timer.  */
      96  
      97  void timevar_push (timevar_id_t timevar);
      98  
      99  /* Pop the topmost timing variable element off the timing stack.  The
     100     popped variable must be TIMEVAR.  Elapsed time since the that
     101     element was pushed on, or since it was last exposed on top of the
     102     stack when the element above it was popped off, is credited to that
     103     timing variable.  */
     104  
     105  void timevar_pop (timevar_id_t timevar);
     106  
     107  /* Start timing TIMEVAR independently of the timing stack.  Elapsed
     108     time until timevar_stop is called for the same timing variable is
     109     attributed to TIMEVAR.  */
     110  
     111  void timevar_start (timevar_id_t timevar);
     112  
     113  /* Stop timing TIMEVAR.  Time elapsed since timevar_start was called
     114     is attributed to it.  */
     115  
     116  void timevar_stop (timevar_id_t timevar);
     117  
     118  /* Fill the elapsed time for TIMEVAR into ELAPSED.  Returns
     119     update-to-date information even if TIMEVAR is currently running.  */
     120  
     121  void timevar_get (timevar_id_t timevar, struct timevar_time_def *elapsed);
     122  
     123  /* Summarize timing variables to FP.  The timing variable TV_TOTAL has
     124     a special meaning -- it's considered to be the total elapsed time,
     125     for normalizing the others, and is displayed last.  */
     126  
     127  void timevar_print (FILE *fp);
     128  
     129  /* Set to to nonzero to enable timing variables.  All the timevar
     130     functions make an early exit if timevar is disabled.  */
     131  
     132  extern int timevar_enabled;
     133  
     134  # ifdef  __cplusplus
     135  }
     136  # endif
     137  
     138  #endif /* ! _TIMEVAR_H */