X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=gold%2Ftimer.cc;h=49e3c141b2c25716bae3b7d3407e3c5dd0fff667;hb=d4693039f950eefb983a66e3270209b738e4ce8a;hp=d9b8874a59c3cff4c8538d8fc1449d68512abd62;hpb=9b547ce6834ed6367db2e76b2c4c2e99b188fc9b;p=deliverable%2Fbinutils-gdb.git diff --git a/gold/timer.cc b/gold/timer.cc index d9b8874a59..49e3c141b2 100644 --- a/gold/timer.cc +++ b/gold/timer.cc @@ -1,6 +1,6 @@ // timer.cc -- helper class for time accounting -// Copyright 2009, 2010 Free Software Foundation, Inc. +// Copyright (C) 2009-2019 Free Software Foundation, Inc. // Written by Rafael Avila de Espindola . // This file is part of gold. @@ -22,6 +22,8 @@ #include "gold.h" +#include + #ifdef HAVE_TIMES #include #endif @@ -49,6 +51,15 @@ Timer::start() this->get_time(&this->start_time_); } +// Record the time used by pass N (0 <= N <= 2). +void +Timer::stamp(int n) +{ + gold_assert(n >= 0 && n <= 2); + TimeStats& thispass = this->pass_times_[n]; + this->get_time(&thispass); +} + #if HAVE_SYSCONF && defined _SC_CLK_TCK # define TICKS_PER_SECOND sysconf (_SC_CLK_TCK) /* POSIX 1003.1-1996 */ #else @@ -106,4 +117,17 @@ Timer::get_elapsed_time() return delta; } +// Return the stats for pass N (0 <= N <= 2). +Timer::TimeStats +Timer::get_pass_time(int n) +{ + gold_assert(n >= 0 && n <= 2); + TimeStats thispass = this->pass_times_[n]; + TimeStats& lastpass = n > 0 ? this->pass_times_[n-1] : this->start_time_; + thispass.wall -= lastpass.wall; + thispass.user -= lastpass.user; + thispass.sys -= lastpass.sys; + return thispass; +} + }