# CPU usage seemingly capped (different from the 2019 question on this topic)

**URL:** <https://discourse.processing.org/t/cpu-usage-seemingly-capped-different-from-the-2019-question-on-this-topic/34440>\
**Category:** Development\
**Created:** [January 3, 2022, 1:47pm UTC](https://discourse.processing.org/t/cpu-usage-seemingly-capped-different-from-the-2019-question-on-this-topic/34440 "2022-01-03T13:47:22Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![AlDickins](https://avatars.discourse-cdn.com/v4/letter/a/958977/32.png) [@AlDickins](https://discourse.processing.org/u/AlDickins)\
**Post date:** [January 3, 2022, 1:47pm UTC](https://discourse.processing.org/t/cpu-usage-seemingly-capped-different-from-the-2019-question-on-this-topic/34440/1 "2022-01-03T13:47:22Z")

</div>

I want my Processing sketch to run with the CPU close to 100% utilisation, compared with the current 14%.

My Processing sketch trains a neural network for a puzzle where a mouse learns to evade a cat which is pursuing it. I was expecting the CPU to run fast (\>80%) through the iterations, but what happens is that it uses almost no CPU: Task Manager shows two processes called Java ™ SE Binary, whose total CPU usage is typically 1 to 5% while the total CPU usage is about 14%. Memory is 76% used (650MB Microsoft Edge, 266 JAVA Platform SE binary, 100 MB Microsoft Word, a few small others).

This programme does calculations only and no drawing (not even setting the canvas background), and does not access any external resources eg a webpage.

My aim is for the programme to run the CPU nearer 100%, which will dramatically reduce the long times currently needed for training.

I have tried:

- Changing the Windows power setting helped: System → power and battery → power mode. Changing to BALANCED or BEST PERFORMANCE had the same result, completing a generation of mice in 40% of the time used when I selected BEST POWER EFFICIENCY, although there is no difference to the total CPU usage or CPU usage by Processing (14% and 2% respectively, the same as when BEST POWER EFFICIENCY is selected).
- Checking whether the programme is doing any unnecessary work (it isn’t).
- Changing the task priority in Task Manager (can’t find how to do it in this version of Windows, but in any case it only makes a difference when the CPU is working hard)
- This post discusses related issues. I don’t understand multiple threads in a programme, but I believe that they wouldn’t help in this case because each generation has to complete before the next one can be calculated. [Processing seemingly capped at 35% cpu - Processing - Processing Foundation](https://discourse.processing.org/t/processing-seemingly-capped-at-35-cpu/11872/17)

The code is something like this:

```auto
/* Declarations and initialisations */

void setup () {
size(1,1);
}

void draw() {

for (int generation = 0; generation < maxGenerations; generation++) {
   for (int i=0; i< maxIterations && ! mouse[i].finished; i++) {
      mouse[i].update();
      cat.update();
      }
   calcualtions_and_reporting_on_completed_generation();
   makeNextGenerationOfMiceByCrossoverAndMutation();
   }
}

```

---

<div class="post-metadata">

**Author:** ![micycle](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/micycle/32/201_2.png) [@micycle](https://discourse.processing.org/u/micycle)\
**Post date:** [January 3, 2022, 4:30pm UTC](https://discourse.processing.org/t/cpu-usage-seemingly-capped-different-from-the-2019-question-on-this-topic/34440/2 "2022-01-03T16:30:48Z")

</div>

Your program uses a single thread, which runs on a single CPU core.

Now, even when program fully utilises the core it runs on, the **overall** CPU usage is limited to `100 / # of cores`%. In an 8 core/thread processor then, a single-threaded application can only use 12.5% CPU at most, which is similar to what you’re experiencing.
