-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStatView.cpp
More file actions
206 lines (160 loc) · 4.48 KB
/
StatView.cpp
File metadata and controls
206 lines (160 loc) · 4.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
// StatView.cpp : implementation file
//
#include "stdafx.h"
#include "WinEVE.h"
#include "StatView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CStatView
IMPLEMENT_DYNCREATE(CStatView, CScrollView)
CStatView::CStatView()
{
}
CStatView::~CStatView()
{
}
BEGIN_MESSAGE_MAP(CStatView, CScrollView)
//{{AFX_MSG_MAP(CStatView)
ON_WM_KEYDOWN()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CStatView drawing
void CStatView::OnInitialUpdate()
{
CScrollView::OnInitialUpdate();
CSize sizeTotal;
// TODO: calculate the total size of this view
sizeTotal.cx = 250;
sizeTotal.cy = 300;
SetScrollSizes(MM_TEXT, sizeTotal);
font.CreateFont(15,0,0,0,400,FALSE,FALSE,0,
ANSI_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,
DEFAULT_QUALITY,DEFAULT_PITCH|FF_MODERN,"Courier New");
}
void CStatView::OnDraw(CDC* pDC)
{
CWinEVEDoc* pDoc = GetDocument();
char txt[100];
pDC->SelectObject(&font);
pDC->SetTextColor(RGB(255,0,0));
pDC->TextOut(0,0," Execution");
pDC->SetTextColor(RGB(0,0,0));
if (pDoc->cycles==1)
sprintf_s(txt,100," 1 Cycle");
else
sprintf_s(txt,100," %d Cycles",pDoc->cycles);
pDC->TextOut(0,20,txt);
if (pDoc->instructions==1)
sprintf_s(txt,100," 1 Instruction");
else
sprintf_s(txt,100," %d Instructions",pDoc->instructions);
pDC->TextOut(0,34,txt);
if (pDoc->instructions>0)
{
sprintf_s(txt,100," %3.3f Cycles Per Instruction (CPI)",(double)pDoc->cycles/pDoc->instructions);
pDC->TextOut(0,48,txt);
}
pDC->SetTextColor(RGB(255,0,0));
/*
pDC->TextOut(0,70," Instruction type");
pDC->SetTextColor(RGB(0,0,0));
sprintf(txt," %d Loads",pDoc->loads);
pDC->TextOut(0,90,txt);
sprintf(txt," %d Stores",pDoc->stores);
pDC->TextOut(0,104,txt);
sprintf(txt," %d Branches taken",pDoc->branches_taken);
pDC->TextOut(0,120,txt);
sprintf(txt," %d Branches not taken",pDoc->branches_not_taken);
pDC->TextOut(0,134,txt);
sprintf(txt," %d Branches Total",pDoc->branches_not_taken+pDoc->branches_taken);
pDC->TextOut(0,148,txt);
*/
pDC->SetTextColor(RGB(255,0,0));
pDC->TextOut(0,90," Stalls");
pDC->SetTextColor(RGB(0,0,0));
if (pDoc->raw_stalls==1)
sprintf_s(txt,100," 1 RAW Stall");
else
sprintf_s(txt,100," %d RAW Stalls",pDoc->raw_stalls);
pDC->TextOut(0,110,txt);
if(pDoc->waw_stalls==1)
sprintf_s(txt,100," 1 WAW Stall");
else
sprintf_s(txt,100," %d WAW Stalls",pDoc->waw_stalls);
pDC->TextOut(0,124,txt);
if (pDoc->war_stalls==1)
sprintf_s(txt,100," 1 WAR Stall");
else
sprintf_s(txt,100," %d WAR Stalls",pDoc->war_stalls);
pDC->TextOut(0,138,txt);
if (pDoc->structural_stalls==1)
sprintf_s(txt,100," 1 Structural Stall");
else
sprintf_s(txt,100," %d Structural Stalls",pDoc->structural_stalls);
pDC->TextOut(0,152,txt);
if (pDoc->branch_taken_stalls==1)
sprintf_s(txt,100," 1 Branch Taken Stall");
else
sprintf_s(txt,100," %d Branch Taken Stalls",pDoc->branch_taken_stalls);
pDC->TextOut(0,166,txt);
if (pDoc->branch_misprediction_stalls==1)
sprintf_s(txt,100," 1 Branch Misprediction Stall");
else
sprintf_s(txt,100," %d Branch Misprediction Stalls",pDoc->branch_misprediction_stalls);
pDC->TextOut(0,180,txt);
pDC->SetTextColor(RGB(255,0,0));
pDC->TextOut(0,222," Code size");
pDC->SetTextColor(RGB(0,0,0));
sprintf_s(txt,100," %d Bytes",pDoc->codeptr);
pDC->TextOut(0,242,txt);
}
/////////////////////////////////////////////////////////////////////////////
// CStatView diagnostics
#ifdef _DEBUG
void CStatView::AssertValid() const
{
CScrollView::AssertValid();
}
void CStatView::Dump(CDumpContext& dc) const
{
CScrollView::Dump(dc);
}
CWinEVEDoc* CStatView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CWinEVEDoc)));
return (CWinEVEDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CStatView message handlers
void CStatView::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
switch (nChar)
{
case VK_HOME:
OnVScroll(SB_TOP,0,NULL);
break;
case VK_END:
OnVScroll(SB_BOTTOM,0,NULL);
break;
case VK_UP:
OnVScroll(SB_LINEUP,0,NULL);
break;
case VK_DOWN:
OnVScroll(SB_LINEDOWN,0,NULL);
break;
default:
break;
}
CScrollView::OnKeyDown(nChar, nRepCnt, nFlags);
}
void CStatView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint)
{
if (lHint==2) return;
InvalidateRect(NULL);
}