Search code examples
processing.js

Processing get higher max frameRate


So I just recently kind of had a breakthrough in Neural Nets and made a couple of games with NN AI's. For training, I use frameRate(100000) to jack the frame rate up. However, checking with println(frameRate) I see that the average frame rate is about 270. Removing all displays (drawing shapes pretty much) increases it to about 300.

I'd like to make it faster, I noticed the documentation states the frameRate() only goes as high as your processor can handle, but checking with task manager I see the program is only using about 20% of my CPU and only 90MB. I've increased the maximum available memory to 4096MB in preferences, but that didn't seem to make a difference.

So I guess my question is, how do I allow processing to use more of my CPU for faster frameRate [or is there a better option other than simply "optimizing my code", because its already fairly optimized IMO (not saying it couldn't be better though)].


Solution

  • Keep in mind that even with a very high framerate, the mechanisms that call draw() have some overhead that you don't need if you aren't drawing anything. Your computer might limit the frame rate depending on your graphics settings. Also note that the println() statement itself is very slow, so you should not use it for continuously printing out your frame rate.

    If you aren't drawing anything (or if you're only drawing a single frame), you can probably just use a basic loop instead of the draw() function.

    Instead, try something like this:

    boolean running = true;
    while(running){
      // do your processing
      if(done){
        running = false;
      }
    }