MrTanoshii / rusty-autoclicker

A pure Rust portable auto clicker built for Linux, macOS & Windows.
Creative Commons Zero v1.0 Universal
74 stars 12 forks source link

reduce CPU usage #45

Open correabuscar opened 1 year ago

correabuscar commented 1 year ago

On Windows even if auto-clicking isn't enabled, due to egui/eframe it seems, there's something like 6% CPU usage(on 12 cores cpu (6+6)) constantly(more or less) but which noticeably turns on CPU fans to audible sounds for me, compared to when rust-autoclicker isn't running at all.

this probably cannot be fixed... i don't know.

EDIT: it's less noticeable if build with --release EDIT2: even with --release but in Gentoo Linux, the cpu usage is between 18.8% and 20% constantly, as reported by top, and makes X process stay at a constant 9.9% to 10.9% as well instead of the usual 1.0% to 2.0%. But at least in Linux here the fans aren't spinning up and it seems the cpu speed isn't going higher than the minimum of 800Mhz (when using the powersave governor)

MrTanoshii commented 1 year ago

I see what you mean

Tested quickly using the trusty windows task manager on a i7-7500U CPU

Unfocus:

Focused (Idle & autoclicking):

Seems to be an issue of the app doing too many things when focused, I'll look into slowing things down when not autoclicking. Maybe the refresh rate is too high?

correabuscar commented 1 year ago

I have noticed that this https://github.com/emilk/eframe_template doesn't use any CPU at all(on Linux), so maybe it is possible to reduce the refresh rate as you say. Or maybe somehow only update when needed, although, you're showing the current mouse coords in real time.

My problem was mostly when unfocused and not autoclicking, and it's mostly 2-3% cpu usage with --release now, when unfocused and idle. I don't hear fans spinning up now. Don't try it without --release :)

MrTanoshii commented 7 months ago

Performance may be improved by following recommendations from

https://github.com/imgui-rs/imgui-rs/issues/678#issuecomment-1323223723