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 "make-unique.h"
#include "timevar.def"
Include dependency graph for timevar.cc:

Data Structures

class  timer::named_items
 

Macros

#define GGC_MEM_BOUND   (1 << 20)
 
#define DEFTIMEVAR(identifier__, name__)
 
#define nanosec_to_floating_sec(NANO)
 
#define percent_of(TOTAL, SUBTOTAL)
 

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)
 
std::unique_ptr< 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__ )
Value:
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_to_floating_sec

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

Referenced by make_json_for_timevar_time_def(), timer::print(), and timer::print_row().

◆ percent_of

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

Referenced by timer::print_row().

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, and define HAVE_WALL_TIME if there.   

References timevar_time_def::ggc_mem, NULL, timevar_ggc_mem_total, and timevar_time_def::wall.

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()

std::unique_ptr< 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 timevar_time_def::ggc_mem, make_unique(), nanosec_to_floating_sec, and timevar_time_def::wall.

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.

◆ timevar_accumulate()

static void timevar_accumulate ( struct timevar_time_def * timer,
struct timevar_time_def * start_time,
struct timevar_time_def * stop_time )
static
Add the difference between STOP_TIME and START_TIME to TIMER.   

References timevar_time_def::ggc_mem, and timevar_time_def::wall.

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

◆ 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(), and g_timer.

◆ 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 timevar_time_def::ggc_mem, 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

timer* g_timer
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/>.   
Non-NULL if timevars should be used.  In GCC, this happens with
the -ftime-report flag.   

Referenced by compiler_data_hooks::add_sarif_invocation_properties(), initialize_rtl(), timevar_cond_start(), timevar_cond_stop(), timevar_init(), timevar_pop(), timevar_push(), timevar_start(), timevar_stop(), toplev::toplev(), and toplev::~toplev().

◆ 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().