GCC Middle and Back End API Reference
timer Class Reference

#include <timevar.h>

Collaboration diagram for timer:

Data Structures

class  named_items
 
struct  timevar_def
 
struct  timevar_stack_def
 

Public Member Functions

 timer ()
 
 ~timer ()
 
void start (timevar_id_t tv)
 
void stop (timevar_id_t tv)
 
void push (timevar_id_t tv)
 
void pop (timevar_id_t tv)
 
bool cond_start (timevar_id_t tv)
 
void cond_stop (timevar_id_t tv)
 
void push_client_item (const char *item_name)
 
void pop_client_item ()
 
void print (FILE *fp)
 
std::unique_ptr< json::valuemake_json () const
 
const char * get_topmost_item_name () const
 

Private Types

typedef hash_map< timevar_def *, timevar_time_defchild_map_t
 

Private Member Functions

void validate_phases (FILE *fp) const
 
void push_internal (struct timevar_def *tv)
 
void pop_internal ()
 

Static Private Member Functions

static void print_row (FILE *fp, const timevar_time_def *total, const char *name, const timevar_time_def &elapsed)
 
static bool all_zero (const timevar_time_def &elapsed)
 

Private Attributes

timevar_def m_timevars [TIMEVAR_LAST]
 
timevar_stack_defm_stack
 
timevar_stack_defm_unused_stack_instances
 
timevar_time_def m_start_time
 
named_itemsm_jit_client_items
 

Friends

class named_items
 

Detailed Description

The public (within GCC) interface for timing.   

Member Typedef Documentation

◆ child_map_t

Constructor & Destructor Documentation

◆ timer()

timer::timer ( )
Class timer's constructor.   
This file contains the definitions for timing variables used to
measure run-time performance of the compiler.
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/>.   
This file contains timing variable definitions, used by timevar.h
and timevar.cc.

Syntax:

  DEFTIMEVAR (id, name)

where ID is the enumeral value used to identify the timing
variable, and NAME is a character string describing its purpose.   
The total execution time.   
The compiler phases.

These must be mutually exclusive, and the NAME field must begin
with "phase".

Also, their sum must be within a millionth of the total time (see
validate_phases).   
Concurrent timers, indicated by "|".   
Time spent garbage-collecting.   
Time spent generating dump files.   
Time spent saving/restoring PCH state.   
Time spent by constructing CFG.   
Time spent by cleaning up CFG.   
Time spent in dataflow problems.   
Timing in various stages of the compiler.   
Everything else in rest_of_compilation not included above.   
Stuff used by libgccjit.so.   
Analyzer timevars.   

References m_timevars.

◆ ~timer()

timer::~timer ( )

Member Function Documentation

◆ all_zero()

bool timer::all_zero ( const timevar_time_def & elapsed)
staticprivate
Return whether ELAPSED is all zero.   

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

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

◆ cond_start()

◆ cond_stop()

◆ get_topmost_item_name()

const char * timer::get_topmost_item_name ( ) const
Get the name of the topmost item.  For use by jit for validating
inputs to gcc_jit_timer_pop.   

References m_stack, timer::timevar_def::name, NULL, and timer::timevar_stack_def::timevar.

◆ make_json()

◆ pop()

void timer::pop ( timevar_id_t timevar)
Pop the topmost timing variable element off the timing stack.  The
popped variable must be TIMEVAR.  Elapsed time since the that
element was pushed on, or since it was last exposed on top of the
stack when the element above it was popped off, is credited to that
timing variable.   

References gcc_assert, m_stack, m_timevars, pop_internal(), and timer::timevar_stack_def::timevar.

Referenced by timevar_pop(), and auto_timevar::~auto_timevar().

◆ pop_client_item()

void timer::pop_client_item ( )
Pop the top-most client item from the timing stack.   

References gcc_assert, m_jit_client_items, and timer::named_items::pop().

◆ pop_internal()

void timer::pop_internal ( )
private
Pop the topmost item from the stack, either one of the builtin ones
for a timevar_id_t, or one provided by client code to libgccjit.   

References timer::timevar_def::children, timer::timevar_def::elapsed, hash_map< KeyId, Value, Traits >::get_or_insert(), get_time(), m_stack, m_start_time, m_unused_stack_instances, timer::timevar_stack_def::next, timer::timevar_stack_def::timevar, and timevar_accumulate().

Referenced by pop().

◆ print()

◆ print_row()

void timer::print_row ( FILE * fp,
const timevar_time_def * total,
const char * name,
const timevar_time_def & elapsed )
staticprivate
Helper function for timer::print.   

References timevar_time_def::ggc_mem, nanosec_to_floating_sec, percent_of, PRsa, SIZE_AMOUNT, and timevar_time_def::wall.

Referenced by print().

◆ push()

void timer::push ( timevar_id_t timevar)
Push TIMEVAR onto the timing stack.  No further elapsed time is
attributed to the previous topmost timing variable on the stack;
subsequent elapsed time is attributed to TIMEVAR, until it is
popped or another element is pushed on top.

TIMEVAR cannot be running as a standalone timer.   

References m_timevars, and push_internal().

Referenced by auto_timevar::auto_timevar(), auto_timevar::auto_timevar(), and timevar_push().

◆ push_client_item()

void timer::push_client_item ( const char * item_name)
Push the named item onto the timing stack.   

References gcc_assert, m_jit_client_items, named_items, and timer::named_items::push().

◆ push_internal()

void timer::push_internal ( struct timevar_def * tv)
private
Push TV onto the timing stack, either one of the builtin ones
for a timevar_id_t, or one provided by client code to libgccjit.   

References timer::timevar_def::elapsed, gcc_assert, get_time(), m_stack, m_start_time, m_unused_stack_instances, timer::timevar_stack_def::next, NULL, timer::timevar_def::standalone, timer::timevar_stack_def::timevar, timevar_accumulate(), and timer::timevar_def::used.

Referenced by push().

◆ start()

void timer::start ( timevar_id_t timevar)

◆ stop()

◆ validate_phases()

void timer::validate_phases ( FILE * fp) const
private

Friends And Related Symbol Documentation

◆ named_items

friend class named_items
friend

Referenced by push_client_item().

Field Documentation

◆ m_jit_client_items

named_items* timer::m_jit_client_items
private

◆ m_stack

◆ m_start_time

timevar_time_def timer::m_start_time
private

Referenced by pop_internal(), print(), and push_internal().

◆ m_timevars

◆ m_unused_stack_instances

timevar_stack_def* timer::m_unused_stack_instances
private

Referenced by pop_internal(), push_internal(), and ~timer().


The documentation for this class was generated from the following files: