Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(238)

Unified Diff: runtime/vm/timer.h

Issue 1841213003: Move CompilerStats from isolate to thread. Aggregate stats. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: review comments addressed Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/thread.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_; }
« no previous file with comments | « runtime/vm/thread.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698