# How to increase Processing's processing power?

**URL:** <https://discourse.processing.org/t/how-to-increase-processings-processing-power/15851>\
**Category:** Coding Questions\
**Created:** [November 26, 2019, 11:24pm UTC](https://discourse.processing.org/t/how-to-increase-processings-processing-power/15851 "2019-11-26T23:24:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mrwizard487](https://avatars.discourse-cdn.com/v4/letter/m/aca169/32.png) [@mrwizard487](https://discourse.processing.org/u/mrwizard487)\
**Post date:** [November 26, 2019, 11:24pm UTC](https://discourse.processing.org/t/how-to-increase-processings-processing-power/15851/1 "2019-11-26T23:24:31Z")

</div>

Hey guys, so I'm currently working on a game in Processing 3 on my 2018 macbook pro. This game  
involves drawing a lot of rectangles, and despite my best optimization efforts, the game suffers from   
frame rates dropping to only 50% in some areas. Are there any techniques for cranking the  
maximum amount of computing power out of Processing?

---

<div class="post-metadata">

**Author:** ![kll](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kll/32/964_2.png) [@kll](https://discourse.processing.org/u/kll)\
**Post date:** [November 27, 2019, 4:33am UTC](https://discourse.processing.org/t/how-to-increase-processings-processing-power/15851/2 "2019-11-27T04:33:55Z")

</div>

there can not be one answer for this.

-a- to get more power out of your computer / cpu  
[https://processing.org/reference/thread\_.html](https://processing.org/reference/thread_.html)  
might help

-b- to shift between speed and quality? test  
[https://processing.org/reference/noSmooth\_.html](https://processing.org/reference/noSmooth_.html)

-c- main factor will be the

- renderer
- canvas size

you might play about this using

```auto

float rset=120, r;
int x = 0;
int w = 400;
int h = 200;
int grid=20, many = grid*grid;
boolean stressenable=true;

void settings() {
  //size(w, h); // default use JAVA2D 
  // size(w, h,FX2D);
  // size(w, h,P2D);
    size(w, h,P3D);
}

void setup() {
  frameRate(rset);
  background(200, 200, 0);
  numinfo();
  sysinfo();
  println("\nstresstest ( "+grid+"*"+grid+" = "+many+" ) points, [+][-] grid +-5" );
}

void draw() {
  surface.setTitle("SYS INFO set "+rset+": "+ nf(r, 0, 1)+" FPS" );
  if ( stressenable ) stress();
  r = frameRate;
  if ( r > 30 ) stroke(0, 200, 0); 
  else stroke(200, 0, 0);
  line(x, height-2, x, height-2-r); // FPS graph
  x++;
  if ( x > width ) { 
    x = 0; 
    background(200, 200, 0);
  }
}

void stress() {
  push();
  for ( int i=0; i<grid; i++) {
    for ( int j=0; j<grid; j++) {
      stroke(random(255), random(255), random(255) );
      point(5+i, 5+j);
    }
  }
  pop();
}

void sysinfo() {
  println( "__SYS INFO :");
  println( "System : " + System.getProperty("os.name") + " " + System.getProperty("os.version") );// + " " + System.getProperty("os.arch") );
  println( "JAVA : " + System.getProperty("java.home") + " rev: " +javaVersionName);
  //println( System.getProperty("java.class.path") );
  //println( "\n" + isGL() + "\n" );
  println( "OPENGL : VENDOR " + PGraphicsOpenGL.OPENGL_VENDOR+" RENDERER " + PGraphicsOpenGL.OPENGL_RENDERER+" VERSION " + PGraphicsOpenGL.OPENGL_VERSION+" GLSL_VERSION: " + PGraphicsOpenGL.GLSL_VERSION);
  println( "user.home : " + System.getProperty("user.home") );
  println( "user.dir : " + System.getProperty("user.dir") );
  println( "user.name : " + System.getProperty("user.name") );
  println( "sketchPath : " + sketchPath() );
  println( "dataPath : " + dataPath("") );
  println( "dataFile : " + dataFile("") );
  println( "frameRate : target "+nf(rset, 0, 1)+" actual "+nf(r, 0, 1));
  println( "canvas : width "+width+" height "+height+" pix "+(width*height));
}

void numinfo() {
  println( "__NUM INFO :");
  println( "byte "+Byte.SIZE+ " bit | min: "+Byte.MIN_VALUE+ "\t\t\t max: "+Byte.MAX_VALUE);
  println( "short "+Short.SIZE+ " bit | min: "+Short.MIN_VALUE+ "\t\t\t max: "+Short.MAX_VALUE);
  println( "int "+Integer.SIZE+" bit | min: "+Integer.MIN_VALUE+"\t\t max: " +Integer.MAX_VALUE);
  println( "long "+Long.SIZE+ " bit | min: "+Long.MIN_VALUE+ "\t max: " +Long.MAX_VALUE);
  println( "float "+Float.SIZE+ " bit | min: "+Float.MIN_VALUE+ "\t\t\t max: "+Float.MAX_VALUE);
  println( "double "+Double.SIZE+ " bit | min: "+Double.MIN_VALUE+ "\t\t\t max: "+Double.MAX_VALUE);
}

void keyPressed() {
  if ( key == 's' ) stressenable = ! stressenable;
  if ( key == '+' ) {
    grid +=5;
    many = grid*grid;
    println("stresstest ( "+grid+"*"+grid+" = "+many+" ) points" );
  }
  if ( key == '-' ) {
    grid -=5;
    many = grid*grid;
    println("stresstest ( "+grid+"*"+grid+" = "+many+" ) points" );
  }
}

```

-d- code optimization not means

- to get max out of your hardware,
- better get it usable even on budget systems.  
( i can test it for you on my Raspberry Pi 3 )

---

<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:** [November 27, 2019, 11:14am UTC](https://discourse.processing.org/t/how-to-increase-processings-processing-power/15851/3 "2019-11-27T11:14:33Z")

</div>

Some other suggestions:

- Use `FX2D` / `P2D` renderer modes.
- Cache rasterisation (calls to `rect()`, etc.) into `PImage` objects.
- Use [PThreading](https://discourse.processing.org/t/pthreading-a-framework-for-multithreaded-drawing-in-processing/14782) (for multithreaded drawing).
