Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow changing the number of CPU cores to use while doing folder comp… #1945

Merged
merged 5 commits into from
Jul 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions Docs/Users/ChangeLog.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ <h3 id="file-compare">File compare</h3>
<h3 id="folder-compare">Folder compare</h3>
<ul>
<li>BugFix: Treeview scrolls to the wrong position. (#1915)</li>
<li>Allow changing the number of CPU cores to use while doing folder comparison (PR #1945)</li>
</ul>
<h3 id="webpage-compare">Webpage compare</h3>
<ul>
<li>Add support for generating report files (PR #1941)</li>
</ul>
<h3 id="command-line">Command line</h3>
<ul>
Expand Down Expand Up @@ -198,7 +203,7 @@ <h3 id="image-compare-1">Image compare</h3>
<ul>
<li>BugFix: Fixed issue preventing saving image comparison reports to a network share</li>
</ul>
<h3 id="webpage-compare">Webpage compare</h3>
<h3 id="webpage-compare-1">Webpage compare</h3>
<ul>
<li>BugFix: Fixed issue with missing file path in header bar</li>
</ul>
Expand Down Expand Up @@ -280,7 +285,7 @@ <h3 id="binary-compare-1">Binary compare</h3>
<ul>
<li>BugFix: Fixed issue where the Open menu item in file path bar of binary comparison window was disabled.</li>
</ul>
<h3 id="webpage-compare-1">Webpage compare</h3>
<h3 id="webpage-compare-2">Webpage compare</h3>
<ul>
<li>BugFix: Deleted color of Word Difference in Options dialog was not used.</li>
<li>Implemented Ignore numbers comparison option.</li>
Expand Down Expand Up @@ -466,7 +471,7 @@ <h3 id="table-compare-2">Table compare</h3>
<ul>
<li>Bugfix: Inline differences ware not displayed even if the caret is moved to the position of an inline difference that is hidden due to the narrow column width.</li>
</ul>
<h3 id="webpage-compare-2">Webpage compare</h3>
<h3 id="webpage-compare-3">Webpage compare</h3>
<ul>
<li>[EXPERIMENTAL] Webpage Compare: Highlight differences (PR #1357)</li>
</ul>
Expand Down Expand Up @@ -580,7 +585,7 @@ <h3 id="image-compare-2">Image compare</h3>
<li>BugFix: Fix an issue where the pane was split vertically the next time the window was displayed, even though the &quot;Split Vertically&quot; menu item was unchecked.</li>
<li>Make patience and histogram diff algorithm selectable.</li>
</ul>
<h3 id="webpage-compare-3">Webpage compare</h3>
<h3 id="webpage-compare-4">Webpage compare</h3>
<ul>
<li>BugFix: Fix text disappearing when pressing the &#39;K&#39; key in the address bar</li>
<li>BugFix: Fix an issue where the pane was split vertically the next time the window was displayed, even though the &quot;Split Vertically&quot; menu item was unchecked.</li>
Expand Down Expand Up @@ -656,7 +661,7 @@ <h3 id="file-compare-10">File compare</h3>
<ul>
<li>BugFix: Fixed a problem where the caret would not display in the correct position on lines containing tab characters, depending on the font in use (osdn.net #44417)</li>
</ul>
<h3 id="webpage-compare-4">Webpage compare</h3>
<h3 id="webpage-compare-5">Webpage compare</h3>
<ul>
<li>Webpage Compare [EXPERIMENTAL] (PR #1182)
<ul>
Expand Down
6 changes: 6 additions & 0 deletions Docs/Users/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@
### Folder compare

- BugFix: Treeview scrolls to the wrong position. (#1915)
- Allow changing the number of CPU cores to use while doing folder comparison
(PR #1945)

### Webpage compare

- Add support for generating report files (PR #1941)

### Command line

Expand Down
5 changes: 5 additions & 0 deletions Docs/Users/ReleaseNotes.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ <h3 id="file-compare">File compare</h3>
<h3 id="folder-compare">Folder compare</h3>
<ul>
<li>BugFix: Treeview scrolls to the wrong position. (#1915)</li>
<li>Allow changing the number of CPU cores to use while doing folder comparison (PR #1945)</li>
</ul>
<h3 id="webpage-compare">Webpage compare</h3>
<ul>
<li>Add support for generating report files (PR #1941)</li>
</ul>
<h3 id="command-line">Command line</h3>
<ul>
Expand Down
6 changes: 6 additions & 0 deletions Docs/Users/ReleaseNotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ Please submit bug reports to our bug-tracker.
### Folder compare

- BugFix: Treeview scrolls to the wrong position. (#1915)
- Allow changing the number of CPU cores to use while doing folder comparison
(PR #1945)

### Webpage compare

- Add support for generating report files (PR #1941)

### Command line

Expand Down
1 change: 1 addition & 0 deletions Src/CompareStats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ CompareStats::CompareStats(int nDirs)
, m_bCompareDone(false)
, m_nDirs(nDirs)
, m_counts()
, m_nIdleCompareThreadCount(0)
{
}

Expand Down
18 changes: 17 additions & 1 deletion Src/CompareStats.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,27 @@ class CompareStats

explicit CompareStats(int nDirs);
~CompareStats();
int GetCompareThreadCount()
{
return static_cast<int>(m_rgThreadState.size());
}
void SetCompareThreadCount(int nCompareThreads)
{
m_rgThreadState.clear();
m_rgThreadState.resize(nCompareThreads);
}
int GetIdleCompareThreadCount() const
{
return m_nIdleCompareThreadCount;
}
void SetIdleCompareThreadCount(int nIdleCompareThreadCount)
{
m_nIdleCompareThreadCount = nIdleCompareThreadCount;
}
bool IsIdleCompareThread(int iCompareThread) const
{
return iCompareThread >= (m_rgThreadState.size() - m_nIdleCompareThreadCount);
}
void BeginCompare(const DIFFITEM *di, int iCompareThread)
{
ThreadState &rThreadState = m_rgThreadState[iCompareThread];
Expand Down Expand Up @@ -109,7 +125,7 @@ class CompareStats
const DIFFITEM *m_pDiffItem;
};
std::vector<ThreadState> m_rgThreadState;

int m_nIdleCompareThreadCount;
};

/**
Expand Down
33 changes: 33 additions & 0 deletions Src/DirCompProgressBar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,17 +90,48 @@ BOOL DirCompProgressBar::Create(CWnd* pParentWnd)
void DirCompProgressBar::SetProgressState(int comparedItems, int totalItems)
{
CProgressCtrl *pProg = (CProgressCtrl*) GetDlgItem(IDC_PROGRESSCOMPARE);
String itemsPerSecond = m_prevComparedItems.empty() ? _T("") : strutils::format(_("%.1f[items/sec]"),
(double)(comparedItems - m_prevComparedItems.front()) * 1000.0 / (UPDATE_INTERVAL * m_prevComparedItems.size()));
SetDlgItemInt(IDC_ITEMSTOTAL, totalItems);
SetDlgItemInt(IDC_ITEMSCOMPARED, comparedItems);
SetDlgItemText(IDC_ITEMS_PER_SEC, itemsPerSecond);
pProg->SetPos(comparedItems);
pProg->SetRange32(0, totalItems);
m_prevComparedItems.push_back(comparedItems);
if (m_prevComparedItems.size() > 10)
m_prevComparedItems.pop_front();

#ifdef __ITaskbarList3_INTERFACE_DEFINED__
if (m_pTaskbarList != nullptr)
m_pTaskbarList->SetProgressValue(AfxGetMainWnd()->m_hWnd, comparedItems, totalItems);
#endif
}

void DirCompProgressBar::SetNumberOfCPUCoresToUseMax(int max)
{
CComboBox * cbo = (CComboBox *)GetDlgItem(IDC_COMPARISON_CPUCORES);
if (!cbo)
return;
cbo->ResetContent();
for (int i = 1; i <= max; ++i)
cbo->AddString(strutils::format(_T("%3d"), i).c_str());
}

int DirCompProgressBar::GetNumberOfCPUCoresToUse() const
{
CComboBox * cbo = (CComboBox *)GetDlgItem(IDC_COMPARISON_CPUCORES);
if (!cbo)
return 0;
return cbo->GetCurSel() + 1;
}

void DirCompProgressBar::SetNumberOfCPUCoresToUse(int num)
{
CComboBox * cbo = (CComboBox *)GetDlgItem(IDC_COMPARISON_CPUCORES);
if (cbo)
cbo->SetCurSel(num - 1);
}

/**
* @brief Timer message received.
* Handle timer messages. When timer fires, update the dialog.
Expand Down Expand Up @@ -131,6 +162,8 @@ void DirCompProgressBar::OnTimer(UINT_PTR nIDEvent)
{
// Start comparing, init progressDlg
SetProgressState(m_pCompareStats->GetComparedItems(), m_pCompareStats->GetTotalItems());
SetNumberOfCPUCoresToUseMax(m_pCompareStats->GetCompareThreadCount());
SetNumberOfCPUCoresToUse(m_pCompareStats->GetCompareThreadCount());
m_prevState = CompareStats::STATE_COMPARE;
}
// Comparing items
Expand Down
4 changes: 4 additions & 0 deletions Src/DirCompProgressBar.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ class DirCompProgressBar : public CTrDialogBar
void StartUpdating();
void EndUpdating();
void SetPaused(bool paused);
int GetNumberOfCPUCoresToUse() const;
void SetNumberOfCPUCoresToUse(int num);

// Dialog Data
//{{AFX_DATA(DirCompProgressBar)
Expand All @@ -52,6 +54,7 @@ class DirCompProgressBar : public CTrDialogBar
protected:
void ClearStat();
void SetProgressState(int comparedItems, int totalItems);
void SetNumberOfCPUCoresToUseMax(int max);

// Generated message map functions
//{{AFX_MSG(DirCompProgressBar)
Expand All @@ -63,6 +66,7 @@ class DirCompProgressBar : public CTrDialogBar
CompareStats *m_pCompareStats; /**< Pointer to comparestats */
CompareStats::CMP_STATE m_prevState; /**< Previous state for compare (to track changes) */
bool m_bCompareReady; /**< Compare ready, waiting for closing? */
std::list<int> m_prevComparedItems;
#ifdef __ITaskbarList3_INTERFACE_DEFINED__
ITaskbarList3 *m_pTaskbarList;
#endif
Expand Down
10 changes: 10 additions & 0 deletions Src/DirDoc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ BEGIN_MESSAGE_MAP(CDirDoc, CDocument)
ON_BN_CLICKED(IDC_COMPARISON_STOP, OnBnClickedComparisonStop)
ON_BN_CLICKED(IDC_COMPARISON_PAUSE, OnBnClickedComparisonPause)
ON_BN_CLICKED(IDC_COMPARISON_CONTINUE, OnBnClickedComparisonContinue)
ON_CBN_SELCHANGE(IDC_COMPARISON_CPUCORES, OnCbnSelChangeCPUCores)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()

Expand Down Expand Up @@ -333,6 +334,7 @@ void CDirDoc::Rescan()
pf->GetHeaderInterface()->Resize();
int nPane = GetOptionsMgr()->GetInt(OPT_ACTIVE_PANE);
m_pDirView->SetActivePane((nPane >= 0 && nPane < m_nDirs) ? nPane : 0);
m_pDirView->GetParentFrame()->SetStatus(_("Comparing items...").c_str());

// Show current compare method name and active filter name in statusbar
pf->SetFilterStatusDisplay(theApp.GetGlobalFileFilter()->GetFilterNameOrMask().c_str());
Expand Down Expand Up @@ -1026,3 +1028,11 @@ void CDirDoc::OnBnClickedComparisonContinue()
ContinueCurrentScan();
}

void CDirDoc::OnCbnSelChangeCPUCores()
{
if (!m_pCmpProgressBar)
return;
m_pCtxt->m_pCompareStats->SetIdleCompareThreadCount(
m_pCtxt->m_pCompareStats->GetCompareThreadCount() - m_pCmpProgressBar->GetNumberOfCPUCoresToUse()
);
}
1 change: 1 addition & 0 deletions Src/DirDoc.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ class CDirDoc : public CDocument, public IMDITab
afx_msg void OnBnClickedComparisonStop();
afx_msg void OnBnClickedComparisonPause();
afx_msg void OnBnClickedComparisonContinue();
afx_msg void OnCbnSelChangeCPUCores();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()

Expand Down
8 changes: 8 additions & 0 deletions Src/DirScan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,13 @@ class DiffWorker: public Runnable
CompareDiffItem(fc, pWorkNf->data());
pWorkNf->queueResult().enqueueNotification(new WorkCompletedNotification(pWorkNf->data()));
}
if (m_pCtxt->m_pCompareStats->IsIdleCompareThread(m_id))
{
m_pCtxt->m_pCompareStats->BeginCompare(nullptr, m_id);
while (!m_pCtxt->ShouldAbort() && m_pCtxt->m_pCompareStats->IsIdleCompareThread(m_id))
Poco::Thread::sleep(10);
}

pNf = m_queue.waitDequeueNotification();
}
}
Expand Down Expand Up @@ -499,6 +506,7 @@ int DirScan_CompareItems(DiffFuncStruct *myStruct, DIFFITEM *parentdiffpos)

int res = CompareItems(queue, myStruct, parentdiffpos);

myStruct->context->m_pCompareStats->SetIdleCompareThreadCount(0);
Thread::sleep(100);
queue.wakeUpAll();
threadPool.joinAll();
Expand Down
20 changes: 13 additions & 7 deletions Src/Merge.rc
Original file line number Diff line number Diff line change
Expand Up @@ -1643,16 +1643,18 @@ IDD_DIRCOMP_PROGRESS DIALOGEX 0, 0, 256, 60
STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD
FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN
DEFPUSHBUTTON "Stop",IDC_COMPARISON_STOP,184,9,65,14
PUSHBUTTON "Pause",IDC_COMPARISON_PAUSE,113,9,65,14
DEFPUSHBUTTON "Stop",IDC_COMPARISON_STOP,184,4,65,14
PUSHBUTTON "Pause",IDC_COMPARISON_PAUSE,113,4,65,14
PUSHBUTTON "Continue",IDC_COMPARISON_CONTINUE,113,9,65,14,NOT WS_VISIBLE
CONTROL "",IDC_PROGRESSCOMPARE,"msctls_progress32",WS_BORDER,7,44,241,10
RTEXT "0",IDC_ITEMSCOMPARED,95,29,60,10
RTEXT "0",IDC_ITEMSTOTAL,95,19,60,10
LTEXT "Comparing items...",IDC_STATIC,7,7,98,10
LTEXT "Items compared:",IDC_STATIC,7,29,85,10
LTEXT "&Number of CPU cores to use:",IDC_STATIC,7,7,110,10
LTEXT "Items total:",IDC_STATIC,7,19,85,10
LTEXT "",IDC_PATH_COMPARING,167,29,111,10
LTEXT "Items compared:",IDC_STATIC,7,31,85,10
COMBOBOX IDC_COMPARISON_CPUCORES,125,5,30,70,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
RTEXT "0",IDC_ITEMSTOTAL,95,19,60,10
RTEXT "0",IDC_ITEMSCOMPARED,95,31,60,10
LTEXT "",IDC_ITEMS_PER_SEC,167,19,85,10
LTEXT "",IDC_PATH_COMPARING,167,31,111,10
END

IDD_WMGOTO DIALOGEX 0, 0, 218, 80
Expand Down Expand Up @@ -2488,6 +2490,8 @@ BEGIN
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 100, 0
END

Expand Down Expand Up @@ -3314,6 +3318,8 @@ STRINGTABLE
BEGIN
IDS_DIRVIEW_STATUS_FMT_FOCUS "Item %1 of %2"
IDS_DIRVIEW_STATUS_FMT_NOFOCUS "Items: %1"
IDS_DIRVIEW_STATUS_COMPARING "Comparing items..."
IDS_ITEMS_PER_SEC "%.1f[items/sec]"
END

// OPEN DIALOG
Expand Down
46 changes: 25 additions & 21 deletions Src/resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -294,27 +294,28 @@
#define IDC_COMPARISON_STOP 1108
#define IDC_COMPARISON_PAUSE 1109
#define IDC_COMPARISON_CONTINUE 1110
#define IDC_DIFF_INCLCMDLINE 1111
#define IDC_WMGOTO_FILELEFT 1112
#define IDC_WMGOTO_FILEMIDDLE 1113
#define IDC_WMGOTO_FILERIGHT 1114
#define IDC_WMGOTO_TOLINE 1115
#define IDC_WMGOTO_TODIFF 1116
#define IDC_WMGOTO_PARAM 1117
#define IDC_WMGOTO_RANGE 1118
#define IDC_OPEN_CONTRIBUTORS 1119
#define IDC_COMPAREMETHODCOMBO 1120
#define IDC_USE_RECYCLE_BIN 1121
#define IDC_COMPARE_DEFAULTS 1122
#define IDC_DIFF_DEFAULTS 1123
#define IDC_MOVED_BLOCKS 1124
#define IDC_RESET_ALL_MESSAGE_BOXES 1125
#define IDC_COLDLG_DEFAULTS 1126
#define IDC_COLDLG_ADDITIONAL_PROPERTIES 1127
#define IDC_OPEN_STATUS 1128
#define IDC_FILTERFILE_EDITBTN 1129
#define IDC_FILTERFILE_LIST 1130
#define IDC_ESC_CLOSES_WINDOW 1131
#define IDC_COMPARISON_CPUCORES 1111
#define IDC_DIFF_INCLCMDLINE 1112
#define IDC_WMGOTO_FILELEFT 1113
#define IDC_WMGOTO_FILEMIDDLE 1114
#define IDC_WMGOTO_FILERIGHT 1115
#define IDC_WMGOTO_TOLINE 1116
#define IDC_WMGOTO_TODIFF 1117
#define IDC_WMGOTO_PARAM 1118
#define IDC_WMGOTO_RANGE 1119
#define IDC_OPEN_CONTRIBUTORS 1120
#define IDC_COMPAREMETHODCOMBO 1121
#define IDC_USE_RECYCLE_BIN 1122
#define IDC_COMPARE_DEFAULTS 1123
#define IDC_DIFF_DEFAULTS 1124
#define IDC_MOVED_BLOCKS 1125
#define IDC_RESET_ALL_MESSAGE_BOXES 1126
#define IDC_COLDLG_DEFAULTS 1127
#define IDC_COLDLG_ADDITIONAL_PROPERTIES 1128
#define IDC_OPEN_STATUS 1129
#define IDC_FILTERFILE_EDITBTN 1130
#define IDC_FILTERFILE_LIST 1131
#define IDC_ESC_CLOSES_WINDOW 1132
#define IDC_STATIC_TITLE_PANE0 1133
#define IDC_STATIC_TITLE_PANE1 1134
#define IDC_STATIC_TITLE_PANE2 1135
Expand Down Expand Up @@ -592,6 +593,7 @@
#define IDC_COMPAREWEBPAGE_URLPATTERNTOEXCLUDE 1428
#define IDC_JUMP_LIST 1429
#define IDC_CLEAR_ALL_RECENT_ITEMS 1430
#define IDC_ITEMS_PER_SEC 1431
#define IDC_EXPAND_SUBDIRS 1600
#define IDC_FILEENCODING 1601
#define IDC_PLUGIN 1602
Expand Down Expand Up @@ -1183,6 +1185,7 @@
#define IDS_STATUSBAR_READONLY 40839
#define IDS_DIRVIEW_STATUS_FMT_FOCUS 40840
#define IDS_DIRVIEW_STATUS_FMT_NOFOCUS 40841
#define IDS_DIRVIEW_STATUS_COMPARING 40842
#define IDS_ERROR_INCOMPARABLE 41200
#define IDS_DIRSEL_TAG 41201
#define IDS_OPEN_FILESDIRS 41202
Expand Down Expand Up @@ -1632,6 +1635,7 @@
#define IDS_JUMPLIST_NEW_IMAGE_COMPARE 44523
#define IDS_JUMPLIST_NEW_WEBPAGE_COMPARE 44524
#define IDS_JUMPLIST_CLIPBOARD_COMPARE 44525
#define IDS_ITEMS_PER_SEC 44526

// Next default values for new objects
//
Expand Down
Loading