-
-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #32 from Calinou/add-various-benchmarks
- Loading branch information
Showing
17 changed files
with
863 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
extends Benchmark | ||
|
||
signal emitter | ||
|
||
const ITERATIONS = 2_000_000 | ||
|
||
func function_callable() -> void: | ||
pass | ||
|
||
|
||
func benchmark_function_callable() -> void: | ||
for i in ITERATIONS: | ||
function_callable.call() | ||
|
||
|
||
func benchmark_lambda_inline_callable() -> void: | ||
for i in ITERATIONS: | ||
(func lambda_callable() -> void: pass).call() | ||
|
||
|
||
func benchmark_lambda_variable_callable() -> void: | ||
var variable_callable := \ | ||
func lambda_callable() -> void: | ||
pass | ||
|
||
for i in ITERATIONS: | ||
variable_callable.call() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
extends Benchmark | ||
|
||
const ITERATIONS = 100_000 | ||
|
||
var crypto := Crypto.new() | ||
|
||
|
||
func benchmark_generate_10_random_bytes() -> void: | ||
for i in ITERATIONS: | ||
crypto.generate_random_bytes(10) | ||
|
||
|
||
func benchmark_generate_1k_random_bytes() -> void: | ||
for i in ITERATIONS: | ||
crypto.generate_random_bytes(1000) | ||
|
||
|
||
func benchmark_generate_1m_random_bytes() -> void: | ||
for i in ITERATIONS: | ||
crypto.generate_random_bytes(1_000_000) | ||
|
||
|
||
func benchmark_generate_1g_random_bytes() -> void: | ||
for i in ITERATIONS: | ||
crypto.generate_random_bytes(1_000_000_000) | ||
|
||
|
||
func benchmark_generate_rsa_2048() -> void: | ||
crypto.generate_rsa(2048) | ||
|
||
|
||
func benchmark_generate_rsa_4096() -> void: | ||
crypto.generate_rsa(4096) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
extends Benchmark | ||
|
||
const ITERATIONS = 10_000_000 | ||
const RANDOM_SEED = preload("res://main.gd").RANDOM_SEED | ||
|
||
var rng := RandomNumberGenerator.new() | ||
|
||
func benchmark_global_scope_randi() -> void: | ||
# Reset the random seed to improve reproducibility of this benchmark. | ||
seed(RANDOM_SEED) | ||
for i in ITERATIONS: | ||
randi() | ||
|
||
# Reset the random seed again to improve reproducibility of other benchmarks. | ||
seed(RANDOM_SEED) | ||
|
||
|
||
func benchmark_randi() -> void: | ||
rng.seed = RANDOM_SEED | ||
for i in ITERATIONS: | ||
rng.randi() | ||
rng.seed = RANDOM_SEED | ||
|
||
|
||
func benchmark_global_scope_randf() -> void: | ||
seed(RANDOM_SEED) | ||
for i in ITERATIONS: | ||
randf() | ||
seed(RANDOM_SEED) | ||
|
||
|
||
func benchmark_randf() -> void: | ||
rng.seed = RANDOM_SEED | ||
for i in ITERATIONS: | ||
rng.randf() | ||
rng.seed = RANDOM_SEED | ||
|
||
|
||
func benchmark_global_scope_randi_range() -> void: | ||
seed(RANDOM_SEED) | ||
for i in ITERATIONS: | ||
randi_range(1234, 5678) | ||
seed(RANDOM_SEED) | ||
|
||
|
||
func benchmark_randi_range() -> void: | ||
rng.seed = RANDOM_SEED | ||
for i in ITERATIONS: | ||
rng.randi_range(1234, 5678) | ||
rng.seed = RANDOM_SEED | ||
|
||
|
||
func benchmark_global_scope_randf_range() -> void: | ||
seed(RANDOM_SEED) | ||
for i in ITERATIONS: | ||
randf_range(1234.0, 5678.0) | ||
seed(RANDOM_SEED) | ||
|
||
|
||
func benchmark_randf_range() -> void: | ||
rng.seed = RANDOM_SEED | ||
for i in ITERATIONS: | ||
rng.randf_range(1234.0, 5678.0) | ||
rng.seed = RANDOM_SEED | ||
|
||
|
||
func benchmark_global_scope_randfn() -> void: | ||
seed(RANDOM_SEED) | ||
for i in ITERATIONS: | ||
randfn(10.0, 2.0) | ||
seed(RANDOM_SEED) | ||
|
||
|
||
func benchmark_randfn() -> void: | ||
rng.seed = RANDOM_SEED | ||
for i in ITERATIONS: | ||
rng.randfn(10.0, 2.0) | ||
rng.seed = RANDOM_SEED | ||
|
||
|
||
func benchmark_global_scope_randomize() -> void: | ||
seed(RANDOM_SEED) | ||
for i in ITERATIONS: | ||
randomize() | ||
seed(RANDOM_SEED) | ||
|
||
|
||
func benchmark_randomize() -> void: | ||
rng.seed = RANDOM_SEED | ||
for i in ITERATIONS: | ||
rng.randomize() | ||
rng.seed = RANDOM_SEED |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,39 @@ | ||
extends Benchmark | ||
|
||
signal emitter | ||
signal emitter_params_1(arg1) | ||
signal emitter_params_10(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10) | ||
|
||
func on_emit(): | ||
const ITERATIONS = 1_000_000 | ||
|
||
func on_emit() -> void: | ||
pass | ||
|
||
|
||
func on_emit_params_1(_arg1) -> void: | ||
pass | ||
|
||
|
||
func on_emit_params_10(_arg1, _arg2, _arg3, _arg4, _arg5, _arg6, _arg7, _arg8, _arg9, _arg10) -> void: | ||
pass | ||
|
||
func benchmark_emission(): | ||
|
||
func benchmark_emission_params_0() -> void: | ||
emitter.connect(on_emit) | ||
for i in 1000_000: | ||
for i in ITERATIONS: | ||
emitter.emit() | ||
emitter.disconnect(on_emit) | ||
|
||
|
||
func benchmark_emission_params_1() -> void: | ||
emitter_params_1.connect(on_emit_params_1) | ||
for i in ITERATIONS: | ||
emitter_params_1.emit(i) | ||
emitter_params_1.disconnect(on_emit_params_1) | ||
|
||
|
||
func benchmark_emission_params_10() -> void: | ||
emitter_params_10.connect(on_emit_params_10) | ||
for i in ITERATIONS: | ||
emitter_params_10.emit(i, i, i, i, i, i, i, i, i, i) | ||
emitter_params_10.disconnect(on_emit_params_10) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.