// pdaritDlg.cpp : implementation file // #include "stdafx.h" #include "pdarit.h" #include "pdaritDlg.h" #include "diskfunctions.h" #include "debug.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CPDARitDlg dialog CPDARitDlg::CPDARitDlg(CWnd* pParent /*=NULL*/) : CDialog(CPDARitDlg::IDD, pParent) { //{{AFX_DATA_INIT(CPDARitDlg) //}}AFX_DATA_INIT // Note that LoadIcon does not require a subsequent DestroyIcon in Win32 m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); } void CPDARitDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CPDARitDlg) DDX_Control(pDX, IDC_CHECKWRITE, m_cDoWrite); DDX_Control(pDX, IDC_EDITWRITESPEED, m_cWriteSpeed); DDX_Control(pDX, IDC_EDITREADSPEED, m_cReadSpeed); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CPDARitDlg, CDialog) //{{AFX_MSG_MAP(CPDARitDlg) ON_BN_CLICKED(IDC_BUTTONTEST, OnButtontest) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CPDARitDlg message handlers BOOL CPDARitDlg::OnInitDialog() { CDialog::OnInitDialog(); // Set the icon for this dialog. The framework does this automatically // when the application's main window is not a dialog SetIcon(m_hIcon, TRUE); // Set big icon SetIcon(m_hIcon, FALSE); // Set small icon CenterWindow(GetDesktopWindow()); // center to the hpc screen // TODO: Add extra initialization here return TRUE; // return TRUE unless you set the focus to a control } void CPDARitDlg::OnButtontest() { PhysicalDisk dsk; if (dsk.Open(1)) { dsk.DumpInfo(); DWORD t0= GetTickCount(); int size= dsk.blocksize(); BYTE *buf= new BYTE[size]; int blocksread= 0; int lastok= -1; int lastnok= -1; for (int i=0 ; i<4096 ; i++) { if (dsk.ReadBlocks(i, 1, buf, size)) { if (lastnok==i-1) debug("not ok: %d - %d\n", lastok+1, lastnok); lastok= i; blocksread++; } else { if (lastok==i-1) debug("ok: %d - %d\n", lastnok+1, lastok); lastnok= i; } } DWORD t1= GetTickCount(); debug("read: %d blocks in %ld msec\n", blocksread, t1-t0); CString str; str.Format(L"%6.2f", (double)blocksread*size*1000.0/(1024.0*(t1-t0))); m_cReadSpeed.SetWindowText(str); if ((m_cDoWrite.GetState()&3)==0) return; int blockswritten= 0; lastok= lastnok= -1; for (i=0 ; i<256 ; i++) { if (dsk.WriteBlocks(i, 1, buf, size)) { if (lastnok==i-1) debug("not ok: %d - %d\n", lastok+1, lastnok); lastok= i; blockswritten++; } else { if (lastok==i-1) debug("ok: %d - %d\n", lastnok+1, lastok); lastnok= i; } } DWORD t2= GetTickCount(); debug("wrote: %d blocks in %ld msec\n", blockswritten, t2-t1); str.Format(L"%6.2f", (double)blockswritten*size*1000.0/(1024.0*(t2-t1))); m_cWriteSpeed.SetWindowText(str); } }