123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- #ifndef BASE_TIMER_LAP_TIMER_H_
- #define BASE_TIMER_LAP_TIMER_H_
- #include "base/base_export.h"
- #include "base/macros.h"
- #include "base/sequence_checker.h"
- #include "base/time/time.h"
- namespace base {
- class BASE_EXPORT LapTimer {
- public:
- enum class TimerMethod {
-
- kUseThreadTicks,
-
- kUseTimeTicks
- };
- LapTimer(int warmup_laps,
- TimeDelta time_limit,
- int check_interval,
- TimerMethod timing_method = TimerMethod::kUseTimeTicks);
-
- LapTimer(TimerMethod timing_method = TimerMethod::kUseTimeTicks);
-
- void Reset();
-
- void Start();
-
- bool IsWarmedUp() const;
-
-
-
- void NextLap();
-
-
- bool HasTimeLimitExpired() const;
-
- TimeDelta TimePerLap() const;
-
- float LapsPerSecond() const;
-
- int NumLaps() const;
- private:
-
-
- bool HasTimedAllLaps() const;
-
- TimeDelta GetAccumulatedTime() const;
- const int warmup_laps_;
- const TimeDelta time_limit_;
- const int check_interval_;
- const TimerMethod method_;
- ThreadTicks start_thread_ticks_;
- TimeTicks start_time_ticks_;
- ThreadTicks last_timed_lap_end_thread_ticks_;
- TimeTicks last_timed_lap_end_ticks_;
- int num_laps_;
- int remaining_warmups_ = 0;
- int remaining_no_check_laps_ = 0;
- SEQUENCE_CHECKER(sequence_checker_);
- DISALLOW_COPY_AND_ASSIGN(LapTimer);
- };
- }
- #endif
|