mirror of
https://github.com/google/benchmark.git
synced 2025-01-15 06:10:15 +08:00
parent
1ee7bee6c5
commit
bdea5051b0
@ -136,10 +136,14 @@ class PerfCountersMeasurement final {
|
|||||||
// concurrently running with this. This is preferring efficiency to
|
// concurrently running with this. This is preferring efficiency to
|
||||||
// maintainability, because the address of the static can be known at compile
|
// maintainability, because the address of the static can be known at compile
|
||||||
// time.
|
// time.
|
||||||
bool IsValid() const { return counters_.IsValid(); }
|
bool IsValid() const {
|
||||||
|
MutexLock l(mutex_);
|
||||||
|
return counters_.IsValid();
|
||||||
|
}
|
||||||
|
|
||||||
BENCHMARK_ALWAYS_INLINE void Start() {
|
BENCHMARK_ALWAYS_INLINE void Start() {
|
||||||
assert(IsValid());
|
assert(IsValid());
|
||||||
|
MutexLock l(mutex_);
|
||||||
// Tell the compiler to not move instructions above/below where we take
|
// Tell the compiler to not move instructions above/below where we take
|
||||||
// the snapshot.
|
// the snapshot.
|
||||||
ClobberMemory();
|
ClobberMemory();
|
||||||
@ -150,6 +154,7 @@ class PerfCountersMeasurement final {
|
|||||||
BENCHMARK_ALWAYS_INLINE bool Stop(
|
BENCHMARK_ALWAYS_INLINE bool Stop(
|
||||||
std::vector<std::pair<std::string, double>>& measurements) {
|
std::vector<std::pair<std::string, double>>& measurements) {
|
||||||
assert(IsValid());
|
assert(IsValid());
|
||||||
|
MutexLock l(mutex_);
|
||||||
// Tell the compiler to not move instructions above/below where we take
|
// Tell the compiler to not move instructions above/below where we take
|
||||||
// the snapshot.
|
// the snapshot.
|
||||||
ClobberMemory();
|
ClobberMemory();
|
||||||
|
Loading…
Reference in New Issue
Block a user