McSwaggens / linux-csgo-external

CSGO Hack for x64 Linux systems

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

CPU Usage 100%

rpasta42 opened this issue · comments

The new loop for testing keyboard input in main.cpp uses 100% CPU. This can be fixed by adding a small sleep as can be seen here.

Even with a 100millisecond sleep, the bot still eats up around 70% of CPU. But if the sleep is too long, then keyboard presses won't be detected, so I left it at 100 for now.

The way that keypress is tested is also inconsistent for triggerbot, because it scans the internal memory looking for keypress, instead of using X keyboard events in a loop in main.cpp.

Good find!
100ms is way too long though,
because it delays the entire hack (including the trigger bot).
I'm planning on soon making this hack multithreaded in the near future, so we can have some parts of the hack running slower (eg. key input), and other parts of the hack running faster (eg. Trigger bot).
But until then I think we can use a 1 or 2 ms delay and that should stop the hack from consuming 100% CPU.

I made a mistake, I said milliseconds, but usleep takes in microseconds. So pausing it for 100 microseconds makes it use 70% of CPU instead of 100%.

The multi-threaded parts sounds good. What are you planning to use for threading API? C++11 features or classic posix threads?

I'll most likely be using POSIX threads because they're the most familiar, although I don't know at this point in time.