Ninja
StatusPrinter Struct Reference

Implementation of the Status interface that prints the status as human-readable strings to stdout. More...

#include <status_printer.h>

Inheritance diagram for StatusPrinter:

Classes

struct  SlidingRateInfo
 

Public Member Functions

void BuildEdgeFinished (Edge *edge, int64_t start_time_millis, int64_t end_time_millis, ExitStatus exit_code, const std::string &output) override
 
void BuildEdgeStarted (const Edge *edge, int64_t start_time_millis) override
 
void BuildFinished () override
 
void BuildStarted () override
 
void EdgeAddedToPlan (const Edge *edge) override
 Callbacks for the Plan to notify us about adding/removing Edge's.
 
void EdgeRemovedFromPlan (const Edge *edge) override
 
void Error (const char *msg,...) override
 
std::string FormatProgressStatus (const char *progress_status_format, int64_t time_millis) const
 Format the progress status string by replacing the placeholders.
 
void Info (const char *msg,...) override
 
void SetExplanations (Explanations *explanations) override
 Set the |explanations_| pointer. Used to implement -d explain.
 
 StatusPrinter (const BuildConfig &config)
 
void Warning (const char *msg,...) override
 

Static Public Member Functions

static Statusfactory (const BuildConfig &)
 creates the actual implementation
 

Private Member Functions

void PrintStatus (const Edge *edge, int64_t time_millis)
 
void RecalculateProgressPrediction ()
 
template<size_t S>
void SnprintfRate (double rate, char(&buf)[S], const char *format) const
 

Private Attributes

const BuildConfigconfig_
 
int64_t cpu_time_millis_ = 0
 How much cpu clock elapsed so far?
 
SlidingRateInfo current_rate_
 
int64_t eta_predictable_cpu_time_remaining_millis_ = 0
 And how much time will they all take?
 
int64_t eta_predictable_cpu_time_total_millis_ = 0
 And how much time did they all take?
 
int eta_predictable_edges_remaining_ = 0
 Out of all the non-finished edges, for how many do we know previous time?
 
int eta_predictable_edges_total_ = 0
 Out of all the edges, for how many do we know previous time?
 
int eta_unpredictable_edges_remaining_ = 0
 For how many edges we don't know the previous run time?
 
Explanationsexplanations_ = nullptr
 An optional Explanations pointer, used to implement -d explain.
 
int finished_edges_
 
LinePrinter printer_
 Prints progress output.
 
const char * progress_status_format_
 The custom progress status format to use.
 
int running_edges_
 
int started_edges_
 
int64_t time_millis_ = 0
 How much wall clock elapsed so far?
 
double time_predicted_percentage_ = 0.0
 What percentage of predicted total time have elapsed already?
 
int total_edges_
 

Detailed Description

Implementation of the Status interface that prints the status as human-readable strings to stdout.

Definition at line 26 of file status_printer.h.

Constructor & Destructor Documentation

◆ StatusPrinter()

StatusPrinter::StatusPrinter ( const BuildConfig & config)
explicit

Member Function Documentation

◆ BuildEdgeFinished()

◆ BuildEdgeStarted()

void StatusPrinter::BuildEdgeStarted ( const Edge * edge,
int64_t start_time_millis )
overridevirtual

Implements Status.

Definition at line 85 of file status_printer.cc.

References printer_, PrintStatus(), running_edges_, started_edges_, time_millis_, and Edge::use_console().

◆ BuildFinished()

void StatusPrinter::BuildFinished ( )
overridevirtual

Implements Status.

Definition at line 259 of file status_printer.cc.

References printer_.

◆ BuildStarted()

void StatusPrinter::BuildStarted ( )
overridevirtual

Implements Status.

Definition at line 253 of file status_printer.cc.

References finished_edges_, running_edges_, and started_edges_.

Referenced by TEST().

◆ EdgeAddedToPlan()

void StatusPrinter::EdgeAddedToPlan ( const Edge * edge)
overridevirtual

◆ EdgeRemovedFromPlan()

◆ Error()

void StatusPrinter::Error ( const char * msg,
... )
overridevirtual

Implements Status.

Definition at line 451 of file status_printer.cc.

References Error().

Referenced by Error().

◆ factory()

Status * Status::factory ( const BuildConfig & config)
staticinherited

creates the actual implementation

Definition at line 40 of file status_printer.cc.

◆ FormatProgressStatus()

string StatusPrinter::FormatProgressStatus ( const char * progress_status_format,
int64_t time_millis ) const

Format the progress status string by replacing the placeholders.

See the user manual for more information about the available placeholders.

Parameters
progress_status_formatThe format of the progress status.
statusThe status of the edge.

Definition at line 264 of file status_printer.cc.

References current_rate_, Fatal(), finished_edges_, FORMAT_TIME_HMMSS, FORMAT_TIME_MMSS, running_edges_, SnprintfRate(), started_edges_, time_millis_, time_predicted_percentage_, and total_edges_.

Referenced by PrintStatus(), TEST(), and TEST().

◆ Info()

void StatusPrinter::Info ( const char * msg,
... )
overridevirtual

Implements Status.

Definition at line 458 of file status_printer.cc.

References Info().

Referenced by Info().

◆ PrintStatus()

◆ RecalculateProgressPrediction()

◆ SetExplanations()

void StatusPrinter::SetExplanations ( Explanations * explanations)
inlineoverridevirtual

Set the |explanations_| pointer. Used to implement -d explain.

Implements Status.

Definition at line 53 of file status_printer.h.

References explanations_.

◆ SnprintfRate()

template<size_t S>
void StatusPrinter::SnprintfRate ( double rate,
char(&) buf[S],
const char * format ) const
inlineprivate

Definition at line 98 of file status_printer.h.

Referenced by FormatProgressStatus().

◆ Warning()

void StatusPrinter::Warning ( const char * msg,
... )
overridevirtual

Implements Status.

Definition at line 444 of file status_printer.cc.

References Warning().

Referenced by Warning().

Member Data Documentation

◆ config_

const BuildConfig& StatusPrinter::config_
private

Definition at line 60 of file status_printer.h.

Referenced by BuildEdgeFinished(), PrintStatus(), and StatusPrinter().

◆ cpu_time_millis_

int64_t StatusPrinter::cpu_time_millis_ = 0
private

How much cpu clock elapsed so far?

Definition at line 68 of file status_printer.h.

Referenced by BuildEdgeFinished(), and RecalculateProgressPrediction().

◆ current_rate_

SlidingRateInfo StatusPrinter::current_rate_
mutableprivate

Definition at line 129 of file status_printer.h.

Referenced by FormatProgressStatus(), and StatusPrinter().

◆ eta_predictable_cpu_time_remaining_millis_

int64_t StatusPrinter::eta_predictable_cpu_time_remaining_millis_ = 0
private

And how much time will they all take?

Definition at line 81 of file status_printer.h.

Referenced by BuildEdgeFinished(), EdgeAddedToPlan(), EdgeRemovedFromPlan(), and RecalculateProgressPrediction().

◆ eta_predictable_cpu_time_total_millis_

int64_t StatusPrinter::eta_predictable_cpu_time_total_millis_ = 0
private

And how much time did they all take?

Definition at line 76 of file status_printer.h.

Referenced by EdgeAddedToPlan(), EdgeRemovedFromPlan(), and RecalculateProgressPrediction().

◆ eta_predictable_edges_remaining_

int StatusPrinter::eta_predictable_edges_remaining_ = 0
private

Out of all the non-finished edges, for how many do we know previous time?

Definition at line 79 of file status_printer.h.

Referenced by BuildEdgeFinished(), EdgeAddedToPlan(), EdgeRemovedFromPlan(), and RecalculateProgressPrediction().

◆ eta_predictable_edges_total_

int StatusPrinter::eta_predictable_edges_total_ = 0
private

Out of all the edges, for how many do we know previous time?

Definition at line 74 of file status_printer.h.

Referenced by EdgeAddedToPlan(), EdgeRemovedFromPlan(), and RecalculateProgressPrediction().

◆ eta_unpredictable_edges_remaining_

int StatusPrinter::eta_unpredictable_edges_remaining_ = 0
private

For how many edges we don't know the previous run time?

Definition at line 84 of file status_printer.h.

Referenced by BuildEdgeFinished(), EdgeAddedToPlan(), EdgeRemovedFromPlan(), and RecalculateProgressPrediction().

◆ explanations_

Explanations* StatusPrinter::explanations_ = nullptr
private

An optional Explanations pointer, used to implement -d explain.

Definition at line 92 of file status_printer.h.

Referenced by PrintStatus(), and SetExplanations().

◆ finished_edges_

int StatusPrinter::finished_edges_
private

◆ printer_

LinePrinter StatusPrinter::printer_
private

Prints progress output.

Definition at line 89 of file status_printer.h.

Referenced by BuildEdgeFinished(), BuildEdgeStarted(), BuildFinished(), PrintStatus(), and StatusPrinter().

◆ progress_status_format_

const char* StatusPrinter::progress_status_format_
private

The custom progress status format to use.

Definition at line 95 of file status_printer.h.

Referenced by PrintStatus(), and StatusPrinter().

◆ running_edges_

int StatusPrinter::running_edges_
private

◆ started_edges_

int StatusPrinter::started_edges_
private

◆ time_millis_

int64_t StatusPrinter::time_millis_ = 0
private

How much wall clock elapsed so far?

Definition at line 65 of file status_printer.h.

Referenced by BuildEdgeFinished(), BuildEdgeStarted(), FormatProgressStatus(), and RecalculateProgressPrediction().

◆ time_predicted_percentage_

double StatusPrinter::time_predicted_percentage_ = 0.0
private

What percentage of predicted total time have elapsed already?

Definition at line 71 of file status_printer.h.

Referenced by FormatProgressStatus(), and RecalculateProgressPrediction().

◆ total_edges_

int StatusPrinter::total_edges_
private

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