Skip to content

Commit ccb0840

Browse files
committed
page use duration in fraction of seconts
1 parent 69ce205 commit ccb0840

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

src/MemoryPagesPool.cxx

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,13 +448,15 @@ MemoryPage::MemoryPage() {
448448
}
449449

450450
MemoryPage::~MemoryPage() {
451+
//reportPageStates();
451452
}
452453

453454
void MemoryPage::setPageState(PageState s) {
454455
if (s != currentPageState) {
455456
if (currentPageState != PageState::Undefined) {
456457
if (pageStateTimes[(int)currentPageState].t0IsValid) {
457-
pageStateTimes[(int)currentPageState].duration += (std::chrono::duration_cast<std::chrono::seconds>(std::chrono::steady_clock::now() - pageStateTimes[(int)currentPageState].t0)).count();
458+
pageStateTimes[(int)currentPageState].duration +=
459+
(std::chrono::duration<double>(std::chrono::steady_clock::now() - pageStateTimes[(int)currentPageState].t0)).count();
458460
}
459461
pageStateTimes[(int)currentPageState].t0IsValid = 0;
460462
}
@@ -526,3 +528,20 @@ int updatePageStateFromDataBlockContainerReference(DataBlockContainerReference b
526528
if (err) {LOG_CODEWRONG;}
527529
return err;
528530
}
531+
532+
void MemoryPage::reportPageStates() {
533+
double t = 0;
534+
for (int i=0; i<PageState::Undefined; i++) {
535+
t += getPageStateDuration((PageState)i);
536+
}
537+
538+
printf("Page %p : ", getPagePtr());
539+
if (t != 0) {
540+
printf ("%12.6fs\t",t);
541+
for (int i=0; i<PageState::Undefined; i++) {
542+
//printf("%s = %.2f%% ", getPageStateString((PageState)i), getPageStateDuration((PageState)i) * 100 / t);
543+
printf("%.2f%% \t", getPageStateDuration((PageState)i) * 100 / t);
544+
}
545+
}
546+
printf("\n");
547+
}

src/MemoryPagesPool.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ class MemoryPage {
5252
void resetPageStates();
5353
double getPageStateDuration(PageState s);
5454
static const char* getPageStateString(PageState s);
55+
void reportPageStates();
5556

5657
friend class MemoryPagesPool;
5758

0 commit comments

Comments
 (0)