• R/O
  • SSH
  • HTTPS

tortoisesvn: Commit


Commit MetaInfo

Revision4305 (tree)
Zeit2005-09-03 03:32:40
Autorstefankueng

Log Message

Add a test procedure which 'touches' random files to give the file system watcher something to do (effectively a stress test for the watcher).

Ändern Zusammenfassung

Diff

--- trunk/test/Cache/CacheDlg.cpp (revision 4304)
+++ trunk/test/Cache/CacheDlg.cpp (revision 4305)
@@ -75,6 +75,7 @@
7575 ON_WM_QUERYDRAGICON()
7676 //}}AFX_MSG_MAP
7777 ON_BN_CLICKED(IDOK, OnBnClickedOk)
78+ ON_BN_CLICKED(IDC_WATCHTESTBUTTON, OnBnClickedWatchtestbutton)
7879 END_MESSAGE_MAP()
7980
8081
@@ -416,4 +417,73 @@
416417 CloseHandle(hPipe);
417418 }
418419 }
420+}
421+void CCacheDlg::OnBnClickedWatchtestbutton()
422+{
423+ UpdateData();
424+ AfxBeginThread(WatchTestThreadEntry, this);
425+}
426+
427+UINT CCacheDlg::WatchTestThreadEntry(LPVOID pVoid)
428+{
429+ return ((CCacheDlg*)pVoid)->WatchTestThread();
430+}
431+
432+//this is the thread function which calls the subversion function
433+UINT CCacheDlg::WatchTestThread()
434+{
435+ CDirFileEnum direnum(m_sRootPath);
436+ m_filelist.RemoveAll();
437+ CString filepath;
438+ bool bIsDir = false;
439+ while (direnum.NextFile(filepath, &bIsDir))
440+ m_filelist.Add(filepath);
441+
442+ CTime starttime = CTime::GetCurrentTime();
443+ GetDlgItem(IDC_STARTTIME)->SetWindowText(starttime.Format(_T("%H:%M:%S")));
444+ int filecounter = 0;
445+
446+ DWORD startticks = GetTickCount();
447+
448+ CString sNumber;
449+ srand(GetTickCount());
450+ filepath = m_filelist.GetAt(rand() % m_filelist.GetCount());
451+ GetStatusFromRemoteCache(CTSVNPath(m_sRootPath), false);
452+ for (int i=0; i < 30000; ++i)
453+ {
454+ filepath = m_filelist.GetAt(rand() % m_filelist.GetCount());
455+ GetDlgItem(IDC_FILEPATH)->SetWindowText(filepath);
456+ TouchFile(filepath);
457+ sNumber.Format(_T("%d"), i);
458+ GetDlgItem(IDC_DONE)->SetWindowText(sNumber);
459+ }
460+ CTime endtime = CTime::GetCurrentTime();
461+ CString sEnd = endtime.Format(_T("%H:%M:%S"));
462+
463+ DWORD endticks = GetTickCount();
464+
465+ CString sEndText;
466+ sEndText.Format(_T("%s - %d ms"), sEnd, endticks-startticks);
467+
468+ GetDlgItem(IDC_ENDTIME)->SetWindowText(sEndText);
469+
470+ return 0;
471+}
472+
473+void CCacheDlg::TouchFile(const CString& path)
474+{
475+ SetFileAttributes(path, FILE_ATTRIBUTE_NORMAL);
476+ HANDLE hFile = CreateFile(path, GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
477+ if (hFile == INVALID_HANDLE_VALUE)
478+ return;
479+
480+ FILETIME ft;
481+ SYSTEMTIME st;
482+
483+ GetSystemTime(&st); // gets current time
484+ SystemTimeToFileTime(&st, &ft); // converts to file time format
485+ SetFileTime(hFile, // sets last-write time for file
486+ (LPFILETIME) NULL, (LPFILETIME) NULL, &ft);
487+
488+ CloseHandle(hFile);
419489 }
\ No newline at end of file
--- trunk/test/Cache/CacheDlg.h (revision 4304)
+++ trunk/test/Cache/CacheDlg.h (revision 4305)
@@ -26,8 +26,11 @@
2626 virtual BOOL OnInitDialog();
2727 afx_msg void OnPaint();
2828 afx_msg HCURSOR OnQueryDragIcon();
29+ afx_msg void OnBnClickedOk();
30+ afx_msg void OnBnClickedWatchtestbutton();
31+
2932 DECLARE_MESSAGE_MAP()
30- afx_msg void OnBnClickedOk();
33+
3134 CString m_sRootPath;
3235 CStringArray m_filelist;
3336 HANDLE m_hPipe;
@@ -40,4 +43,10 @@
4043 bool EnsurePipeOpen();
4144 bool GetStatusFromRemoteCache(const CTSVNPath& Path, bool bRecursive);
4245 void RemoveFromCache(const CString& path);
46+
47+ void TouchFile(const CString& path);
48+
49+ static UINT WatchTestThreadEntry(LPVOID pVoid);
50+ UINT WatchTestThread();
51+public:
4352 };
--- trunk/test/Cache/resource.h (revision 4304)
+++ trunk/test/Cache/resource.h (revision 4305)
@@ -10,6 +10,8 @@
1010 #define IDC_ENDTIME 1003
1111 #define IDC_EDIT1 1004
1212 #define IDC_ROOTPATH 1004
13+#define IDC_BUTTON1 1005
14+#define IDC_WATCHTESTBUTTON 1005
1315
1416 // Next default values for new objects
1517 //
@@ -17,7 +19,7 @@
1719 #ifndef APSTUDIO_READONLY_SYMBOLS
1820 #define _APS_NEXT_RESOURCE_VALUE 129
1921 #define _APS_NEXT_COMMAND_VALUE 32771
20-#define _APS_NEXT_CONTROL_VALUE 1005
22+#define _APS_NEXT_CONTROL_VALUE 1006
2123 #define _APS_NEXT_SYMED_VALUE 101
2224 #endif
2325 #endif
Show on old repository browser