From 42ba8d19997dc07e06e868cefe30c991911b6b4f Mon Sep 17 00:00:00 2001 From: Francisco Demartino Date: Thu, 1 Feb 2024 14:57:53 -0300 Subject: [PATCH] Add benchmarks for noise (#56) --- benchmarks/math/noise.gd | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 benchmarks/math/noise.gd diff --git a/benchmarks/math/noise.gd b/benchmarks/math/noise.gd new file mode 100644 index 0000000..55f9926 --- /dev/null +++ b/benchmarks/math/noise.gd @@ -0,0 +1,33 @@ +extends Benchmark + +const NUM_ITERATIONS := 1000000 + +func _bench_noise(noise) -> void: + for i in NUM_ITERATIONS: + noise.get_noise_1d(i) + noise.get_noise_2d(i, i) + noise.get_noise_3d(i, i, i) + +func _fast_noise(type: FastNoiseLite.NoiseType) -> FastNoiseLite: + var noise := FastNoiseLite.new() + noise.noise_type = type + noise.seed = 234 + return noise + +func benchmark_value() -> void: + return _bench_noise(_fast_noise(FastNoiseLite.TYPE_VALUE)) + +func benchmark_value_cubic() -> void: + return _bench_noise(_fast_noise(FastNoiseLite.TYPE_VALUE_CUBIC)) + +func benchmark_perlin() -> void: + return _bench_noise(_fast_noise(FastNoiseLite.TYPE_PERLIN)) + +func benchmark_cellular() -> void: + return _bench_noise(_fast_noise(FastNoiseLite.TYPE_CELLULAR)) + +func benchmark_simplex() -> void: + return _bench_noise(_fast_noise(FastNoiseLite.TYPE_SIMPLEX)) + +func benchmark_simplex_smooth() -> void: + return _bench_noise(_fast_noise(FastNoiseLite.TYPE_SIMPLEX_SMOOTH))