-
July 22nd, 2016, 03:07 PM
#1
[RESOLVED] MFC ProgressBar makes Application Slow
Hello
I have a problem with my progress bar:
Code:
std::string line;
std::ifstream infile(ExtractFromFile, std::ios::binary);
while (std::getline(infile, line))
{
MainDialog->StockList.push_back(line.c_str());
TProgressBar.SetStep(1);
TProgressBar.StepIt();
}
My list has about 5 MB. If i use TProgressBar stepit() then it takes about 20 seconds, without it it takes about 1 second. The difference is huge.
Is there any way to make it faster ?
Thank you!
-
July 22nd, 2016, 09:20 PM
#2
Re: MFC ProgressBar makes Application Slow
Change the step size and only set the step on every 10 lines. There's no need to be that granular.
-
July 23rd, 2016, 03:45 AM
#3
Re: MFC ProgressBar makes Application Slow
Why are you setting the step size every time through the loop?
All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!
C++23 Compiler: Microsoft VS2022 (17.6.5)
-
July 24th, 2016, 03:24 PM
#4
Re: MFC ProgressBar makes Application Slow
Code:
int CountNr = 0;
std::string line;
std::ifstream infile(ExtractFromFile, std::ios::binary);
while (std::getline(infile, line))
{
CountNr++;
MainDialog->StockList.push_back(line.c_str());
if (CountNr==10) {
TProgressBar.SetStep(10);
TProgressBar.StepIt(); }
}
Now its 10 times faster.
Thank you guys!
-
July 24th, 2016, 05:01 PM
#5
Re: [RESOLVED] MFC ProgressBar makes Application Slow
Why is SetStep() within the loop?
When CountNr equals 10, shouldn't it be reset to 0?
All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!
C++23 Compiler: Microsoft VS2022 (17.6.5)
-
July 25th, 2016, 07:56 AM
#6
Re: [RESOLVED] MFC ProgressBar makes Application Slow
Code:
int CountNr = 0;
int step = 100;
TProgressBar.SetStep(step);
std::string line;
std::ifstream infile(ExtractFromFile, std::ios::binary);
while (std::getline(infile, line))
{
CountNr++;
MainDialog->StockList.push_back(line.c_str());
if (0 == CountNr % step)
TProgressBar.StepIt();
}
Best regards,
Igor
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|