GCC Middle and Back End API Reference
timevar.cc File Reference
#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "timevar.h"
#include "options.h"
#include "json.h"
#include "timevar.def"
Include dependency graph for timevar.cc:

Data Structures

struct  tms
 
class  timer::named_items
 

Macros

#define RUSAGE_SELF   0
 
#define TICKS_PER_SECOND   100 /* often the correct value @endverbatim */
 
#define NANOSEC_PER_SEC   1000000000
 
#define GGC_MEM_BOUND   (1 << 20)
 
#define DEFTIMEVAR(identifier__, name__)    m_timevars[identifier__].name = name__;
 
#define nanosec_to_floating_sec(NANO)   ((double)(NANO) * 1e-9)
 
#define percent_of(TOTAL, SUBTOTAL)    ((TOTAL) == 0 ? 0 : ((double)SUBTOTAL / TOTAL) * 100)
 

Typedefs

typedef int clock_t
 

Functions

static void get_time (struct timevar_time_def *)
 
static void timevar_accumulate (struct timevar_time_def *, struct timevar_time_def *, struct timevar_time_def *)
 
static void timevar_diff (struct timevar_time_def *out, const timevar_time_def &start_time, const timevar_time_def &stop_time)
 
void timevar_init (void)
 
void timevar_start (timevar_id_t timevar)
 
void timevar_stop (timevar_id_t timevar)
 
bool timevar_cond_start (timevar_id_t timevar)
 
void timevar_cond_stop (timevar_id_t timevar, bool running)
 
json::objectmake_json_for_timevar_time_def (const timevar_time_def &ttd)
 
void print_time (const char *str, long total)
 

Variables

timerg_timer
 
size_t timevar_ggc_mem_total
 

Macro Definition Documentation

◆ DEFTIMEVAR

#define DEFTIMEVAR ( identifier__,
name__ )    m_timevars[identifier__].name = name__;

◆ GGC_MEM_BOUND

#define GGC_MEM_BOUND   (1 << 20)
The amount of memory that will cause us to report the timevar even
if the time spent is not significant.   

Referenced by timer::all_zero().

◆ NANOSEC_PER_SEC

#define NANOSEC_PER_SEC   1000000000
Prefer times to getrusage to clock (each gives successively less
information).   
libc is very likely to have snuck a call to sysconf() into one of
the underlying constants, and that can be very slow, so we have to
precompute them.  Whose wonderful idea was it to make all those
_constants_ variable at run time, anyway?   

Referenced by get_time().

◆ nanosec_to_floating_sec

#define nanosec_to_floating_sec ( NANO)    ((double)(NANO) * 1e-9)

◆ percent_of

#define percent_of ( TOTAL,
SUBTOTAL )    ((TOTAL) == 0 ? 0 : ((double)SUBTOTAL / TOTAL) * 100)

Referenced by timer::print_row().

◆ RUSAGE_SELF

#define RUSAGE_SELF   0

Referenced by get_time().

◆ TICKS_PER_SECOND

#define TICKS_PER_SECOND   100 /* often the correct value @endverbatim */
Calculation of scale factor to convert ticks to seconds.
We mustn't use CLOCKS_PER_SEC except with clock().   

Typedef Documentation

◆ clock_t

Timing variables for measuring compiler performance.
   Copyright (C) 2000-2024 Free Software Foundation, Inc.
   Contributed by Alex Samuel <samuel@codesourcery.com>

This file is part of GCC.

GCC is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 3, or (at your option) any later
version.

GCC is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
for more details.

You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING3.  If not see
<http://www.gnu.org/licenses/>.   

Function Documentation

◆ get_time()

static void get_time ( struct timevar_time_def * now)
static
See timevar.h for an explanation of timing variables.   
Fill the current times into TIME.  The definition of this function
also defines any or all of the HAVE_USER_TIME, HAVE_SYS_TIME, and
HAVE_WALL_TIME macros.   

References ggc_alloc(), NANOSEC_PER_SEC, RUSAGE_SELF, timevar_ggc_mem_total, tms::tms_stime, and tms::tms_utime.

Referenced by timer::cond_start(), timer::cond_stop(), timer::make_json(), timer::pop_internal(), timer::print(), timer::push_internal(), timer::start(), and timer::stop().

◆ make_json_for_timevar_time_def()

json::object * make_json_for_timevar_time_def ( const timevar_time_def & ttd)
Create a json value representing this object, suitable for use
in SARIF output.   

References ggc_alloc(), nanosec_to_floating_sec, json::object::set_float(), and json::object::set_integer().

Referenced by timer::make_json(), and timer::timevar_def::make_json().

◆ print_time()

void print_time ( const char * str,
long total )
Prints a message to stderr stating that time elapsed in STR is
TOTAL (given in microseconds).   

References all_time, and ggc_alloc().

◆ timevar_accumulate()

static void timevar_accumulate ( struct timevar_time_def * timer,
struct timevar_time_def * start_time,
struct timevar_time_def * stop_time )
static

◆ timevar_cond_start()

bool timevar_cond_start ( timevar_id_t timevar)
Conditionally start timing TIMEVAR independently of the timing stack.
If the timer is already running, leave it running and return true.
Otherwise, start the timer and return false.
Elapsed time until the corresponding timevar_cond_stop
is called for the same timing variable is attributed to TIMEVAR.   

References timer::cond_start(), and g_timer.

◆ timevar_cond_stop()

void timevar_cond_stop ( timevar_id_t timevar,
bool running )
Conditionally stop timing TIMEVAR.  The RUNNING parameter must come
from the return value of a dynamically matching timevar_cond_start.
If the timer had already been RUNNING, do nothing.  Otherwise, time
elapsed since timevar_cond_start was called is attributed to it.   

References timer::cond_stop(), g_timer, and ggc_alloc().

◆ timevar_diff()

static void timevar_diff ( struct timevar_time_def * out,
const timevar_time_def & start_time,
const timevar_time_def & stop_time )
static
Get the difference between STOP_TIME and START_TIME.   

References ggc_alloc(), timevar_time_def::ggc_mem, timevar_time_def::sys, timevar_time_def::user, and timevar_time_def::wall.

Referenced by timer::make_json().

◆ timevar_init()

void timevar_init ( void )
Initialize timing variables.   

References g_timer.

Referenced by toplev::start_timevars().

◆ timevar_start()

void timevar_start ( timevar_id_t timevar)
Start timing TIMEVAR independently of the timing stack.  Elapsed
time until timevar_stop is called for the same timing variable is
attributed to TIMEVAR.   

References g_timer, and timer::start().

Referenced by symbol_table::compile(), compile_file(), do_compile(), global_decl_processing(), and toplev::start_timevars().

◆ timevar_stop()

void timevar_stop ( timevar_id_t timevar)
Stop timing TIMEVAR.  Time elapsed since timevar_start was called
is attributed to it.   

References g_timer, and timer::stop().

Referenced by symbol_table::compile(), compile_file(), do_compile(), and global_decl_processing().

Variable Documentation

◆ g_timer

◆ timevar_ggc_mem_total

size_t timevar_ggc_mem_total
Total amount of memory allocated by garbage collector.   

Referenced by get_time(), and ggc_internal_alloc().