Skip to content

Commit e729570

Browse files
committed
pcm-power: refactor
1 parent b08b437 commit e729570

File tree

1 file changed

+26
-20
lines changed

1 file changed

+26
-20
lines changed

src/pcm-power.cpp

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -601,27 +601,8 @@ int mainThrows(int argc, char * argv[])
601601

602602
if (PERF_LIMIT_REASON_TPMI_Supported) PERF_LIMIT_REASON_TPMI::reset(max_pm_modules);
603603

604-
mainLoop([&]()
604+
auto printAll = [&](const int delay_ms)
605605
{
606-
cout << "----------------------------------------------------------------------------------------------\n";
607-
608-
if (!csv) cout << flush;
609-
610-
const auto delay_ms = calibratedSleep(delay, sysCmd, mainLoop, m);
611-
612-
AfterTime = m->getTickCount();
613-
for (i = 0; i < numSockets; ++i)
614-
AfterState[i] = m->getServerUncoreCounterState(i);
615-
616-
m->getAllCounterStates(dummySystemState, afterSocketState, dummyCoreStates, false);
617-
618-
if (PERF_LIMIT_REASON_TPMI_Supported)
619-
{
620-
PERF_LIMIT_REASON_TPMI_dies_data = PERF_LIMIT_REASON_TPMI::readDies();
621-
PERF_LIMIT_REASON_TPMI_modules_data = PERF_LIMIT_REASON_TPMI::readModules(max_pm_modules);
622-
PERF_LIMIT_REASON_TPMI::reset(max_pm_modules);
623-
}
624-
625606
cout << "Time elapsed: " << AfterTime - BeforeTime << " ms\n";
626607
cout << "Called sleep function for " << delay_ms << " ms\n";
627608
for (uint32 socket = 0; socket < numSockets; ++socket)
@@ -886,6 +867,31 @@ int mainThrows(int argc, char * argv[])
886867
cout << "\n";
887868
}
888869
}
870+
};
871+
872+
mainLoop([&]()
873+
{
874+
cout << "----------------------------------------------------------------------------------------------\n";
875+
876+
if (!csv) cout << flush;
877+
878+
const auto delay_ms = calibratedSleep(delay, sysCmd, mainLoop, m);
879+
880+
AfterTime = m->getTickCount();
881+
for (i = 0; i < numSockets; ++i)
882+
AfterState[i] = m->getServerUncoreCounterState(i);
883+
884+
m->getAllCounterStates(dummySystemState, afterSocketState, dummyCoreStates, false);
885+
886+
if (PERF_LIMIT_REASON_TPMI_Supported)
887+
{
888+
PERF_LIMIT_REASON_TPMI_dies_data = PERF_LIMIT_REASON_TPMI::readDies();
889+
PERF_LIMIT_REASON_TPMI_modules_data = PERF_LIMIT_REASON_TPMI::readModules(max_pm_modules);
890+
PERF_LIMIT_REASON_TPMI::reset(max_pm_modules);
891+
}
892+
893+
printAll(delay_ms);
894+
889895
swap(BeforeState, AfterState);
890896
swap(BeforeTime, AfterTime);
891897
swap(beforeSocketState, afterSocketState);

0 commit comments

Comments
 (0)