# Perlin vs Simplex noise performance

**URL:** <https://discourse.processing.org/t/perlin-vs-simplex-noise-performance/4189>\
**Category:** Gallery\
**Created:** [October 6, 2018, 3:08pm UTC](https://discourse.processing.org/t/perlin-vs-simplex-noise-performance/4189 "2018-10-06T15:08:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![hamoid](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/hamoid/32/58_2.png) [@hamoid](https://discourse.processing.org/u/hamoid)\
**Post date:** [October 6, 2018, 3:08pm UTC](https://discourse.processing.org/t/perlin-vs-simplex-noise-performance/4189/1 "2018-10-06T15:08:34Z")

</div>

Initially I wanted to share here a speed comparison between SimplexNoise and Perlin noise, thinking that SimplexNoise was much faster than the standard noise(), but I realized that the main speed difference was caused by noise() being computed over 4 octaves by default when SimplexNoise does only one octave.

I used this to test performance:

```auto
import toxi.math.noise.SimplexNoise;

PApplet Perlin noise

for (int j=0; j<5; j++) {
  // measure standard noise()
  long t0 = System.nanoTime();
  float n = 0;
  for (int i=0; i<500000; i++) {
    n += noise(i * 0.01, i * 0.03);
  }
  long t1 = System.nanoTime();

  // measure SimplexNoise
  long t2 = System.nanoTime();
  n = 0;
  for (int i=0; i<500000; i++) {
    n += SimplexNoise.noise(i * 0.01, i * 0.03);
  }
  long t3 = System.nanoTime();

  println((t1 - t0)/1000000, "ms with PApplet.noise()");
  println((t3 - t2)/1000000, "ms with SimplexNoise.noise()");
  println("SimplexNoise time =", (t3-t2)/(float)(t1-t0), "% of noise time\n");
}

```

Which gave me results like

```bash
63 ms with PApplet.noise()
23 ms with SimplexNoise.noise()
SimplexNoise time = 0.37506297 % of noise time

48 ms with PApplet.noise()
17 ms with SimplexNoise.noise()
SimplexNoise time = 0.3666313 % of noise time

47 ms with PApplet.noise()
18 ms with SimplexNoise.noise()
SimplexNoise time = 0.3852872 % of noise time

50 ms with PApplet.noise()
18 ms with SimplexNoise.noise()
SimplexNoise time = 0.37369484 % of noise time

45 ms with PApplet.noise()
18 ms with SimplexNoise.noise()
SimplexNoise time = 0.40698823 % of noise time

```

When I saw that I thought: wow, that’s a huge performance improvement.

But compare how each noise looks like:  
 ![2018-10-06-172008_500x500_scrot](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/7/7c617d5bfe04d9200ee046f71393477725d421bc.png)

There I realized that noise() was doing 4 octaves because of the nice small details.  
If you call `noiseDetail(1)` you get this:  
 ![2018-10-06-171853_500x500_scrot](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/5/5f257f80201741cee36da2c57e587435c6ff8fa5.jpeg)

Generated with this program:

```auto
import toxi.math.noise.SimplexNoise;

size(500, 500);

noiseDetail(1);
float zoom = 0.03;
for(int y=0; y<height; y++) {
  for(int x=0; x<width; x++) {
    float n;
    if(x<width/2) {
      n = noise(x * zoom, y * zoom);
    } else {
      n = (float)SimplexNoise.noise(x * zoom, y * zoom);
      n = 0.5 + 0.5 * n;
    }
    stroke(n * 255);
    point(x, y);
  }
}

```

And in this case you can see the timing is not that different between both techniques (tiny bit faster for Simplex):

```auto
29 ms with PApplet.noise()
27 ms with SimplexNoise.noise()
SimplexNoise time = 0.9117051 % of noise time

26 ms with PApplet.noise()
18 ms with SimplexNoise.noise()
SimplexNoise time = 0.721629 % of noise time

19 ms with PApplet.noise()
18 ms with SimplexNoise.noise()
SimplexNoise time = 0.92072546 % of noise time

20 ms with PApplet.noise()
18 ms with SimplexNoise.noise()
SimplexNoise time = 0.9038497 % of noise time

19 ms with PApplet.noise()
18 ms with SimplexNoise.noise()
SimplexNoise time = 0.9573687 % of noise time

```

At least it was an interesting find. Also, notice how Perlin noise seems to have 2 axes and low contrast while Simplex has 3 axes and higher contrast.

---

<div class="post-metadata">

**Author:** ![hamoid](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/hamoid/32/58_2.png) [@hamoid](https://discourse.processing.org/u/hamoid)\
**Post date:** [October 6, 2018, 3:52pm UTC](https://discourse.processing.org/t/perlin-vs-simplex-noise-performance/4189/2 "2018-10-06T15:52:22Z")

</div>

Since I started comparing the two, why not continue…

Noise fields comparing both (perlin on the left, the third argument of noise is constant).  
 ![2018-10-06-174735_500x500_scrot](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/e/e71a1aa9c463d445b18bcb51e4d4193fa3b773c2.png)

And same, but third argument is slowly changing time:  
 ![2018-10-06-174832_500x500_scrot](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/9/99fd0021c7a2ad345339a4a50c91d362cb1c3dd2.png)

Rendered with this program:

```auto
import toxi.math.noise.SimplexNoise;

void setup() {
  size(500, 500);
  background(0);
  stroke(255, 50);
  noiseDetail(1);
}
float zoom = 0.03;
void draw() {
  float xx = random(width);
  float yy = random(height);
  for (int i=0; i<500; i++) {
    float a;
    float t = 0; // frameCount * 0.001;
    if (xx<width/2) {
      a = TWO_PI * noise(xx * zoom, yy * zoom, t);
    } else {
      a = PI * (float)(SimplexNoise.noise(xx * zoom, yy * zoom, t));
    }
    xx += cos(a);
    yy += sin(a);
    point(xx, yy);
  }
}

```

---

<div class="post-metadata">

**Author:** ![hamoid](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/hamoid/32/58_2.png) [@hamoid](https://discourse.processing.org/u/hamoid)\
**Post date:** [March 28, 2020, 6:56am UTC](https://discourse.processing.org/t/perlin-vs-simplex-noise-performance/4189/3 "2020-03-28T06:56:56Z")

</div>

Clarification: I called it Perlin Noise because that’s what the reference says, but based on [https://github.com/processing/processing/issues/2550](https://github.com/processing/processing/issues/2550) it is actually Value Noise.
