Skip to content

Commit

Permalink
top fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
profezzorn committed May 25, 2024
1 parent 5c1edfe commit fad953e
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions common/scoped_cycle_counter.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,27 @@ class ScopedCycleCounter {
ScopedCycleCounter(uint64_t& dest) :
dest_(dest) {
#ifndef DISABLE_DIAGNOSTIC_COMMANDS
noInterrupts();
cycles_ = getCycles();
interrupts();
#endif
}
~ScopedCycleCounter() {
#ifndef DISABLE_DIAGNOSTIC_COMMANDS
noInterrupts();
uint32_t cycles;
cycles = getCycles() - cycles_;
noInterrupts();
counted_cycles_ += cycles;
interrupts();
dest_ += cycles;
#endif
}
private:
static uint32_t counted_cycles_;
static volatile uint32_t counted_cycles_;
uint32_t cycles_;
uint64_t& dest_;
};

uint32_t ScopedCycleCounter::counted_cycles_ = 0;
volatile uint32_t ScopedCycleCounter::counted_cycles_ = 0;

#endif

0 comments on commit fad953e

Please sign in to comment.