home *** CD-ROM | disk | FTP | other *** search
- // PerfStatsView.cpp : implementation file
- //
- // This file is part of Microsoft SQL Server online documentation.
- // Copyright (C) 1992-1997 Microsoft Corporation. All rights reserved.
- //
- // This source code is an intended supplement to the Microsoft SQL
- // Server online references and related electronic documentation.
- #include "stdafx.h"
- #include "MFCPerf.h"
- #include "PerfDoc.h"
- #include "PerfView.h"
-
- #include "odbcss.h"
-
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
-
- /////////////////////////////////////////////////////////////////////////////
- // CPerfStatsView
- IMPLEMENT_DYNCREATE(CPerfStatsView, CFormView)
-
- CPerfStatsView::CPerfStatsView()
- : CFormView(CPerfStatsView::IDD)
- {
- //{{AFX_DATA_INIT(CPerfStatsView)
- //}}AFX_DATA_INIT
- }
-
- CPerfStatsView::~CPerfStatsView()
- {
- }
-
- void CPerfStatsView::DoDataExchange(CDataExchange* pDX)
- {
- CFormView::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CPerfStatsView)
- DDX_Control(pDX, IDC_GRID_STATS, m_gridStats);
- //}}AFX_DATA_MAP
- }
-
- BEGIN_MESSAGE_MAP(CPerfStatsView, CFormView)
- //{{AFX_MSG_MAP(CPerfStatsView)
- // NOTE - the ClassWizard will add and remove mapping macros here.
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
-
- /////////////////////////////////////////////////////////////////////////////
- // CPerfStatsView diagnostics
- #ifdef _DEBUG
- void CPerfStatsView::AssertValid() const
- {
- CFormView::AssertValid();
- }
-
- void CPerfStatsView::Dump(CDumpContext& dc) const
- {
- CFormView::Dump(dc);
- }
-
- CPerfStatsDoc* CPerfStatsView::GetDocument() // non-debug version is inline
- {
- ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CPerfStatsDoc)));
- return (CPerfStatsDoc*)m_pDocument;
- }
- #endif //_DEBUG
-
- /////////////////////////////////////////////////////////////////////////////
- // CPerfStatsView message handlers
- void CPerfStatsView::OnInitialUpdate()
- {
- CFormView::OnInitialUpdate();
-
- PTSTR pStatsText[] =
- {
- _T("SQLidu"), _T("SQLiduRows"), _T("SQLSelects"),
- _T("SQLSelectRows"), _T("Transactions"), _T("SQLPrepares"),
- _T("ExecDirects"), _T("SQLExecutes"), _T("CursorOpens"),
- _T("CursorSize"), _T("CursorUsed"), _T("PercentCursorUsed"),
- _T("AvgFetchTime"), _T("AvgCursorSize"), _T("AvgCursorUsed"),
- _T("SQLFetchTime"), _T("SQLFetchCount"), _T("CurrentStmtCount"),
- _T("MaxOpenStmt"), _T("SumOpenStmt"), _T("CurrentConnectionCount"),
- _T("MaxConnectionsOpened"), _T("SumConnectionsOpened"),
- _T("SumConnectiontime"),_T("AvgTimeOpened"), _T("ServerRndTrips"),
- _T("BuffersSent"), _T("BuffersRec"), _T("BytesSent"),
- _T("BytesRec"), _T("msExecutionTime"), _T("msNetWorkServerTime")
- };
-
- RECT rectGrid;
- RECT rectFrame;
- CWnd* wndFrame = this->GetParent();
-
- m_gridStats.GetWindowRect(&rectGrid);
- wndFrame->GetWindowRect(&rectFrame);
-
- rectFrame.bottom = (rectGrid.bottom - rectFrame.top) + 16;
- rectFrame.right = rectFrame.right - rectFrame.left;
- rectFrame.top = 0;
- rectFrame.left = 0;
-
- wndFrame->MoveWindow(&rectFrame);
-
- m_gridStats.SetColWidth(0, 156 * 15);
- m_gridStats.SetColWidth(1, 121 * 15);
- m_gridStats.SetColWidth(2, 121 * 15);
- m_gridStats.SetRow(0);
- m_gridStats.SetCol(0);
- m_gridStats.SetText(_T("Statistic"));
- m_gridStats.SetCol(1);
- m_gridStats.SetText(_T("Slow execution"));
- m_gridStats.SetCol(2);
- m_gridStats.SetText(_T("Fast execution"));
- m_gridStats.SetCol(0);
-
- for (UINT i = 0; i < 32; i++)
- {
- m_gridStats.SetRow(i+1);
- m_gridStats.SetText(pStatsText[i]);
- }
-
- }
-
- void CPerfStatsView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint)
- {
- CPerfStatsDoc* pDocument = GetDocument();
- if (!pDocument->IsModified())
- {
- return;
- }
-
- CString strValue;
-
- m_gridStats.SetRow(1);
-
- strValue.Format(_T("%lu"), pDocument->m_perfSlow.SQLidu);
- m_gridStats.SetCol(1);
- m_gridStats.SetText((LPCTSTR) strValue);
-
- strValue.Format(_T("%lu"), pDocument->m_perfFast.SQLidu);
- m_gridStats.SetCol(2);
- m_gridStats.SetText((LPCTSTR) strValue);
-
- m_gridStats.SetRow(2);
-
- strValue.Format(_T("%lu"), pDocument->m_perfSlow.SQLiduRows);
- m_gridStats.SetCol(1);
- m_gridStats.SetText((LPCTSTR) strValue);
-
- strValue.Format(_T("%lu"), pDocument->m_perfFast.SQLiduRows);
- m_gridStats.SetCol(2);
- m_gridStats.SetText((LPCTSTR) strValue);
-
- m_gridStats.SetRow(3);
-
- strValue.Format(_T("%lu"), pDocument->m_perfSlow.SQLSelects);
- m_gridStats.SetCol(1);
- m_gridStats.SetText((LPCTSTR) strValue);
-
- strValue.Format(_T("%lu"), pDocument->m_perfFast.SQLSelects);
- m_gridStats.SetCol(2);
- m_gridStats.SetText((LPCTSTR) strValue);
-
- m_gridStats.SetRow(4);
-
- strValue.Format(_T("%lu"), pDocument->m_perfSlow.SQLSelectRows);
- m_gridStats.SetCol(1);
- m_gridStats.SetText((LPCTSTR) strValue);
-
- strValue.Format(_T("%lu"), pDocument->m_perfFast.SQLSelectRows);
- m_gridStats.SetCol(2);
- m_gridStats.SetText((LPCTSTR) strValue);
-
- m_gridStats.SetRow(5);
-
- strValue.Format(_T("%lu"), pDocument->m_perfSlow.Transactions);
- m_gridStats.SetCol(1);
- m_gridStats.SetText((LPCTSTR) strValue);
-
- strValue.Format(_T("%lu"), pDocument->m_perfFast.Transactions);
- m_gridStats.SetCol(2);
- m_gridStats.SetText((LPCTSTR) strValue);
-
- m_gridStats.SetRow(6);
-
- strValue.Format(_T("%lu"), pDocument->m_perfSlow.SQLPrepares);
- m_gridStats.SetCol(1);
- m_gridStats.SetText((LPCTSTR) strValue);
-
- strValue.Format(_T("%lu"), pDocument->m_perfFast.SQLPrepares);
- m_gridStats.SetCol(2);
- m_gridStats.SetText((LPCTSTR) strValue);
-
- m_gridStats.SetRow(7);
-
- strValue.Format(_T("%lu"), pDocument->m_perfSlow.ExecDirects);
- m_gridStats.SetCol(1);
- m_gridStats.SetText((LPCTSTR) strValue);
-
- strValue.Format(_T("%lu"), pDocument->m_perfFast.ExecDirects);
- m_gridStats.SetCol(2);
- m_gridStats.SetText((LPCTSTR) strValue);
-
- m_gridStats.SetRow(8);
-
- strValue.Format(_T("%lu"), pDocument->m_perfSlow.SQLExecutes);
- m_gridStats.SetCol(1);
- m_gridStats.SetText((LPCTSTR) strValue);
-
- strValue.Format(_T("%lu"), pDocument->m_perfFast.SQLExecutes);
- m_gridStats.SetCol(2);
- m_gridStats.SetText((LPCTSTR) strValue);
-
- m_gridStats.SetRow(9);
-
- strValue.Format(_T("%lu"), pDocument->m_perfSlow.CursorOpens);
- m_gridStats.SetCol(1);
- m_gridStats.SetText((LPCTSTR) strValue);
-
- strValue.Format(_T("%lu"), pDocument->m_perfFast.CursorOpens);
- m_gridStats.SetCol(2);
- m_gridStats.SetText((LPCTSTR) strValue);
-
- m_gridStats.SetRow(10);
-
- strValue.Format(_T("%lu"), pDocument->m_perfSlow.CursorSize);
- m_gridStats.SetCol(1);
- m_gridStats.SetText((LPCTSTR) strValue);
-
- strValue.Format(_T("%lu"), pDocument->m_perfFast.CursorSize);
- m_gridStats.SetCol(2);
- m_gridStats.SetText((LPCTSTR) strValue);
-
- m_gridStats.SetRow(11);
-
- strValue.Format(_T("%lu"), pDocument->m_perfSlow.CursorUsed);
- m_gridStats.SetCol(1);
- m_gridStats.SetText((LPCTSTR) strValue);
-
- strValue.Format(_T("%lu"), pDocument->m_perfFast.CursorUsed);
- m_gridStats.SetCol(2);
- m_gridStats.SetText((LPCTSTR) strValue);
-
- m_gridStats.SetRow(12);
-
- strValue.Format(_T("%.4f"), pDocument->m_perfSlow.PercentCursorUsed);
- m_gridStats.SetCol(1);
- m_gridStats.SetText((LPCTSTR) strValue);
-
- strValue.Format(_T("%.4f"), pDocument->m_perfFast.PercentCursorUsed);
- m_gridStats.SetCol(2);
- m_gridStats.SetText((LPCTSTR) strValue);
-
- m_gridStats.SetRow(13);
-
- strValue.Format(_T("%.4f"), pDocument->m_perfSlow.AvgFetchTime);
- m_gridStats.SetCol(1);
- m_gridStats.SetText((LPCTSTR) strValue);
-
- strValue.Format(_T("%.4f"), pDocument->m_perfFast.AvgFetchTime);
- m_gridStats.SetCol(2);
- m_gridStats.SetText((LPCTSTR) strValue);
-
- m_gridStats.SetRow(14);
-
- strValue.Format(_T("%.4f"), pDocument->m_perfSlow.AvgCursorSize);
- m_gridStats.SetCol(1);
- m_gridStats.SetText((LPCTSTR) strValue);
-
- strValue.Format(_T("%.4f"), pDocument->m_perfFast.AvgCursorSize);
- m_gridStats.SetCol(2);
- m_gridStats.SetText((LPCTSTR) strValue);
-
- m_gridStats.SetRow(15);
-
- strValue.Format(_T("%.4f"), pDocument->m_perfSlow.AvgCursorUsed);
- m_gridStats.SetCol(1);
- m_gridStats.SetText((LPCTSTR) strValue);
-
- strValue.Format(_T("%.4f"), pDocument->m_perfFast.AvgCursorUsed);
- m_gridStats.SetCol(2);
- m_gridStats.SetText((LPCTSTR) strValue);
-
- m_gridStats.SetRow(16);
-
- strValue.Format(_T("%lu"), pDocument->m_perfSlow.SQLFetchTime);
- m_gridStats.SetCol(1);
- m_gridStats.SetText((LPCTSTR) strValue);
-
- strValue.Format(_T("%lu"), pDocument->m_perfFast.SQLFetchTime);
- m_gridStats.SetCol(2);
- m_gridStats.SetText((LPCTSTR) strValue);
-
- m_gridStats.SetRow(17);
-
- strValue.Format(_T("%lu"), pDocument->m_perfSlow.SQLFetchCount);
- m_gridStats.SetCol(1);
- m_gridStats.SetText((LPCTSTR) strValue);
-
- strValue.Format(_T("%lu"), pDocument->m_perfFast.SQLFetchCount);
- m_gridStats.SetCol(2);
- m_gridStats.SetText((LPCTSTR) strValue);
-
- m_gridStats.SetRow(18);
-
- strValue.Format(_T("%lu"), pDocument->m_perfSlow.CurrentStmtCount);
- m_gridStats.SetCol(1);
- m_gridStats.SetText((LPCTSTR) strValue);
-
- strValue.Format(_T("%lu"), pDocument->m_perfFast.CurrentStmtCount);
- m_gridStats.SetCol(2);
- m_gridStats.SetText((LPCTSTR) strValue);
-
- m_gridStats.SetRow(19);
-
- strValue.Format(_T("%lu"), pDocument->m_perfSlow.MaxOpenStmt);
- m_gridStats.SetCol(1);
- m_gridStats.SetText((LPCTSTR) strValue);
-
- strValue.Format(_T("%lu"), pDocument->m_perfFast.MaxOpenStmt);
- m_gridStats.SetCol(2);
- m_gridStats.SetText((LPCTSTR) strValue);
-
- m_gridStats.SetRow(20);
-
- strValue.Format(_T("%lu"), pDocument->m_perfSlow.SumOpenStmt);
- m_gridStats.SetCol(1);
- m_gridStats.SetText((LPCTSTR) strValue);
-
- strValue.Format(_T("%lu"), pDocument->m_perfFast.SumOpenStmt);
- m_gridStats.SetCol(2);
- m_gridStats.SetText((LPCTSTR) strValue);
-
- m_gridStats.SetRow(21);
-
- strValue.Format(_T("%lu"), pDocument->m_perfSlow.CurrentConnectionCount);
- m_gridStats.SetCol(1);
- m_gridStats.SetText((LPCTSTR) strValue);
-
- strValue.Format(_T("%lu"), pDocument->m_perfFast.CurrentConnectionCount);
- m_gridStats.SetCol(2);
- m_gridStats.SetText((LPCTSTR) strValue);
-
- m_gridStats.SetRow(22);
-
- strValue.Format(_T("%lu"), pDocument->m_perfSlow.MaxConnectionsOpened);
- m_gridStats.SetCol(1);
- m_gridStats.SetText((LPCTSTR) strValue);
-
- strValue.Format(_T("%lu"), pDocument->m_perfFast.MaxConnectionsOpened);
- m_gridStats.SetCol(2);
- m_gridStats.SetText((LPCTSTR) strValue);
-
- m_gridStats.SetRow(23);
-
- strValue.Format(_T("%lu"), pDocument->m_perfSlow.SumConnectionsOpened);
- m_gridStats.SetCol(1);
- m_gridStats.SetText((LPCTSTR) strValue);
-
- strValue.Format(_T("%lu"), pDocument->m_perfFast.SumConnectionsOpened);
- m_gridStats.SetCol(2);
- m_gridStats.SetText((LPCTSTR) strValue);
-
- m_gridStats.SetRow(24);
-
- strValue.Format(_T("%lu"), pDocument->m_perfSlow.SumConnectiontime);
- m_gridStats.SetCol(1);
- m_gridStats.SetText((LPCTSTR) strValue);
-
- strValue.Format(_T("%lu"), pDocument->m_perfFast.SumConnectiontime);
- m_gridStats.SetCol(2);
- m_gridStats.SetText((LPCTSTR) strValue);
-
- m_gridStats.SetRow(25);
-
- strValue.Format(_T("%.4f"), pDocument->m_perfSlow.AvgTimeOpened);
- m_gridStats.SetCol(1);
- m_gridStats.SetText((LPCTSTR) strValue);
-
- strValue.Format(_T("%.4f"), pDocument->m_perfFast.AvgTimeOpened);
- m_gridStats.SetCol(2);
- m_gridStats.SetText((LPCTSTR) strValue);
-
- m_gridStats.SetRow(26);
-
- strValue.Format(_T("%lu"), pDocument->m_perfSlow.ServerRndTrips);
- m_gridStats.SetCol(1);
- m_gridStats.SetText((LPCTSTR) strValue);
-
- strValue.Format(_T("%lu"), pDocument->m_perfFast.ServerRndTrips);
- m_gridStats.SetCol(2);
- m_gridStats.SetText((LPCTSTR) strValue);
-
- m_gridStats.SetRow(27);
-
- strValue.Format(_T("%lu"), pDocument->m_perfSlow.BuffersSent);
- m_gridStats.SetCol(1);
- m_gridStats.SetText((LPCTSTR) strValue);
-
- strValue.Format(_T("%lu"), pDocument->m_perfFast.BuffersSent);
- m_gridStats.SetCol(2);
- m_gridStats.SetText((LPCTSTR) strValue);
-
- m_gridStats.SetRow(28);
-
- strValue.Format(_T("%lu"), pDocument->m_perfSlow.BuffersRec);
- m_gridStats.SetCol(1);
- m_gridStats.SetText((LPCTSTR) strValue);
-
- strValue.Format(_T("%lu"), pDocument->m_perfFast.BuffersRec);
- m_gridStats.SetCol(2);
- m_gridStats.SetText((LPCTSTR) strValue);
-
- m_gridStats.SetRow(29);
-
- strValue.Format(_T("%lu"), pDocument->m_perfSlow.BytesSent);
- m_gridStats.SetCol(1);
- m_gridStats.SetText((LPCTSTR) strValue);
-
- strValue.Format(_T("%lu"), pDocument->m_perfFast.BytesSent);
- m_gridStats.SetCol(2);
- m_gridStats.SetText((LPCTSTR) strValue);
-
- m_gridStats.SetRow(30);
-
- strValue.Format(_T("%lu"), pDocument->m_perfSlow.BytesRec);
- m_gridStats.SetCol(1);
- m_gridStats.SetText((LPCTSTR) strValue);
-
- strValue.Format(_T("%lu"), pDocument->m_perfFast.BytesRec);
- m_gridStats.SetCol(2);
- m_gridStats.SetText((LPCTSTR) strValue);
-
- m_gridStats.SetRow(31);
-
- strValue.Format(_T("%lu"), pDocument->m_perfSlow.msExecutionTime);
- m_gridStats.SetCol(1);
- m_gridStats.SetText((LPCTSTR) strValue);
-
- strValue.Format(_T("%lu"), pDocument->m_perfFast.msExecutionTime);
- m_gridStats.SetCol(2);
- m_gridStats.SetText((LPCTSTR) strValue);
-
- m_gridStats.SetRow(32);
-
- strValue.Format(_T("%lu"), pDocument->m_perfSlow.msNetWorkServerTime);
- m_gridStats.SetCol(1);
- m_gridStats.SetText((LPCTSTR) strValue);
-
- strValue.Format(_T("%lu"), pDocument->m_perfFast.msNetWorkServerTime);
- m_gridStats.SetCol(2);
- m_gridStats.SetText((LPCTSTR) strValue);
-
- pDocument->SetModifiedFlag(FALSE);
- }
-