| Index: runtime/vm/timer.h
|
| diff --git a/runtime/vm/timer.h b/runtime/vm/timer.h
|
| index f3b15fafaa1013fc160b76a00a2446fce467738d..01a6b6fe62d1722866e5a2b5107e84e1331ea781 100644
|
| --- a/runtime/vm/timer.h
|
| +++ b/runtime/vm/timer.h
|
| @@ -7,6 +7,7 @@
|
|
|
| #include "platform/utils.h"
|
| #include "vm/allocation.h"
|
| +#include "vm/atomic.h"
|
| #include "vm/flags.h"
|
| #include "vm/os.h"
|
|
|
| @@ -34,7 +35,8 @@ class Timer : public ValueObject {
|
| stop_ = OS::GetCurrentTimeMicros();
|
| int64_t elapsed = ElapsedMicros();
|
| max_contiguous_ = Utils::Maximum(max_contiguous_, elapsed);
|
| - total_ += elapsed;
|
| + // Make increment atomic in case it occurs in parallel with aggregation.
|
| + AtomicOperations::IncrementInt64By(&total_, elapsed);
|
| running_ = false;
|
| }
|
|
|
| @@ -65,6 +67,15 @@ class Timer : public ValueObject {
|
| running_ = false;
|
| }
|
|
|
| + bool IsReset() const {
|
| + return (start_ == 0) && (stop_ == 0) && (total_ == 0) &&
|
| + (max_contiguous_ == 0) && !running_;
|
| + }
|
| +
|
| + void AddTotal(const Timer& other) {
|
| + AtomicOperations::IncrementInt64By(&total_, other.total_);
|
| + }
|
| +
|
| // Accessors.
|
| bool report() const { return report_; }
|
| bool running() const { return running_; }
|
|
|