MCPcopy Create free account
hub / github.com/ElementsProject/elements / updateResults

Method updateResults

src/bench/nanobench.h:2518–2557  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2516// overflow is ok, it's checked
2517ANKERL_NANOBENCH_NO_SANITIZE("integer", "undefined")
2518void LinuxPerformanceCounters::updateResults(uint64_t numIters) {
2519 // clear old data
2520 for (auto& id_value : mIdToTarget) {
2521 *id_value.second.targetValue = UINT64_C(0);
2522 }
2523
2524 if (mHasError) {
2525 return;
2526 }
2527
2528 mTimeEnabledNanos = mCounters[1] - mCalibratedOverhead[1];
2529 mTimeRunningNanos = mCounters[2] - mCalibratedOverhead[2];
2530
2531 for (uint64_t i = 0; i < mCounters[0]; ++i) {
2532 auto idx = static_cast<size_t>(3 + i * 2 + 0);
2533 auto id = mCounters[idx + 1U];
2534
2535 auto it = mIdToTarget.find(id);
2536 if (it != mIdToTarget.end()) {
2537
2538 auto& tgt = it->second;
2539 *tgt.targetValue = mCounters[idx];
2540 if (tgt.correctMeasuringOverhead) {
2541 if (*tgt.targetValue >= mCalibratedOverhead[idx]) {
2542 *tgt.targetValue -= mCalibratedOverhead[idx];
2543 } else {
2544 *tgt.targetValue = 0U;
2545 }
2546 }
2547 if (tgt.correctLoopOverhead) {
2548 auto correctionVal = mLoopOverhead[idx] * numIters;
2549 if (*tgt.targetValue >= correctionVal) {
2550 *tgt.targetValue -= correctionVal;
2551 } else {
2552 *tgt.targetValue = 0U;
2553 }
2554 }
2555 }
2556 }
2557}
2558
2559bool LinuxPerformanceCounters::monitor(uint32_t type, uint64_t eventid, Target target) {
2560 *target.targetValue = (std::numeric_limits<uint64_t>::max)();

Callers 1

nanobench.hFile · 0.80

Calls 2

findMethod · 0.80
endMethod · 0.45

Tested by

no test coverage detected