Skip to content

Commit

Permalink
Implement core benchmarks: StringName, NodePath, ConfigFile (#40)
Browse files Browse the repository at this point in the history
  • Loading branch information
hakro authored Oct 22, 2023
1 parent f8b40e1 commit 14806b1
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 0 deletions.
38 changes: 38 additions & 0 deletions benchmarks/core/config_file.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
extends Benchmark

const NUM_VALUES := 1000
const ITERATIONS := 50
const CONFIG_FILE := "user://benchmark_config_file.ini"
const CONFIG_FILE_ENCRYPTED := "user://benchmark_config_file.ini.encrypted"
var config: ConfigFile = ConfigFile.new()

func _init() -> void:
create_config_file()
config.save(CONFIG_FILE)
config.save_encrypted_pass(CONFIG_FILE_ENCRYPTED, "PasswordIsGodot")


func create_config_file() -> void:
for i in 1000:
config.set_value("Sec" + str(i % 10), "Key" + str(i), "Val" + str(i))


func benchmark_save() -> void:
for i in ITERATIONS:
config.save(CONFIG_FILE)


func benchmark_load() -> void:
for i in ITERATIONS:
config.load(CONFIG_FILE)


func benchmark_save_with_password() -> void:
for i in ITERATIONS:
config.save_encrypted_pass(CONFIG_FILE_ENCRYPTED, "PasswordIsGodot")


func benchmark_load_with_password() -> void:
for i in ITERATIONS:
config.load_encrypted_pass(CONFIG_FILE_ENCRYPTED, "PasswordIsGodot")

7 changes: 7 additions & 0 deletions benchmarks/core/node_path.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
extends Benchmark

const ITERATIONS = 1_000_000

func benchmark_create() -> void:
for i in ITERATIONS:
var _n: NodePath = "Godot"
7 changes: 7 additions & 0 deletions benchmarks/core/string_name.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
extends Benchmark

const ITERATIONS = 1_000_000

func benchmark_create() -> void:
for i in ITERATIONS:
var _s: StringName = "Godot"

0 comments on commit 14806b1

Please sign in to comment.