If you’re using Swift, I made a custom replacement for NSProgress that is 
specifically designed to cut down on CPU time used to update the progress. It 
allows you to set the granularity for notifications, so that they’ll only 
update when the progress has changed since the last update by an interval of 
your choosing.

You can check it out here if you like:

https://github.com/CharlesJS/CSProgress 
<https://github.com/CharlesJS/CSProgress>

Charles

> On Jul 28, 2017, at 10:57 AM, Mark Allan <markjal...@gmail.com> wrote:
> 
> Hi all,
> 
> I'm wondering if anyone has any thoughts about or links to best practices 
> when using determinate NSProgressIndicators.
> 
> I have an app with a helper tool that performs some lengthy process in a loop 
> and reports progress to the user.  It works out how many iterations of the 
> loop will be needed, sets the progressbar.maxValue, and then increments the 
> progress bar's value on each iteration.
> 
> The consumes a large amount of CPU time just for updating the progress bar, 
> so I'd like to cut down how often I update it.
> 
> Setting the max value to 100 and only updating 100 times (i.e. as a 
> percentage) seems too infrequent because the loop can iterate more than a 
> million times.
> 
> I'm debating doing it with an NSTimer firing every second, but wondered if 
> anyone had any other suggestions?
> 
> What are people's thoughts?
> 
> I've tried searching online and the only problems/solutions I can see are all 
> related to people's progress bars not updating properly because they're 
> blocking the main thread etc. I can't see anything related to best practice.
> 
> Many thanks
> Mark
> 
> PS. It could be that this is a case of premature optimisation...but I don't 
> think so!
> _______________________________________________
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/cocoa-dev/cocoadev%40charlessoft.com
> 
> This email sent to cocoa...@charlessoft.com

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to