Ninja
Classes | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
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:
Inheritance graph
[legend]

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. More...
 
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. More...
 
void Info (const char *msg,...) override
 
void SetExplanations (Explanations *explanations) override
 Set the |explanations_| pointer. Used to implement -d explain. More...
 
 StatusPrinter (const BuildConfig &config)
 
void Warning (const char *msg,...) override
 

Static Public Member Functions

static Statusfactory (const BuildConfig &)
 creates the actual implementation More...
 

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

void StatusPrinter::BuildEdgeFinished ( Edge edge,
int64_t  start_time_millis,
int64_t  end_time_millis,
ExitStatus  exit_code,
const std::string &  output 
)
overridevirtual

◆ BuildEdgeStarted()

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

◆ BuildFinished()

void StatusPrinter::BuildFinished ( )
overridevirtual

Implements Status.

Definition at line 259 of file status_printer.cc.

References printer_, LinePrinter::PrintOnNewLine(), and LinePrinter::SetConsoleLocked().

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

void StatusPrinter::EdgeRemovedFromPlan ( const Edge edge)
overridevirtual

◆ Error()

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

Implements Status.

Definition at line 451 of file status_printer.cc.

◆ 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, StatusPrinter::SlidingRateInfo::rate(), running_edges_, SnprintfRate(), started_edges_, time_millis_, time_predicted_percentage_, total_edges_, and StatusPrinter::SlidingRateInfo::UpdateRate().

Referenced by PrintStatus(), and TEST().

◆ Info()

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

Implements Status.

Definition at line 458 of file status_printer.cc.

◆ PrintStatus()

void StatusPrinter::PrintStatus ( const Edge edge,
int64_t  time_millis 
)
private

◆ RecalculateProgressPrediction()

void StatusPrinter::RecalculateProgressPrediction ( )
private

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

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

◆ 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

Definition at line 62 of file status_printer.h.

Referenced by BuildEdgeStarted(), BuildStarted(), and FormatProgressStatus().

◆ 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: