Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update benchmark and MemoryManager fixes #521

Merged
merged 5 commits into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 0 additions & 78 deletions harness/benchmarks/csharp/Simple.cs

This file was deleted.

2 changes: 1 addition & 1 deletion harness/benchmarks/default_env.tres
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[gd_resource type="Environment" load_steps=2 format=2]

[sub_resource type="ProceduralSky" id=1]
[sub_resource type="Sky" id=1]

[resource]
background_mode = 2
Expand Down
6 changes: 3 additions & 3 deletions harness/benchmarks/gd/Memory.gd
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ var stress_size = 100
func _init():
for i in range(access_size):
objs.append(Node.new())
refs.append(File.new())
refs.append(RefCounted.new())
cores.append(RID())

func _notification(what):
Expand Down Expand Up @@ -45,7 +45,7 @@ func benchmark_stress_object():
func benchmark_stress_reference():
var ref
for i in range(stress_size):
ref = File.new()
ref = RefCounted.new()

func benchmark_stress_core():
var core
Expand All @@ -60,5 +60,5 @@ func benchmark_stress_z_mix():
obj = Node.new()
obj.free()
core = RID()
ref = File.new()
ref = RefCounted.new()

6 changes: 3 additions & 3 deletions harness/benchmarks/gd/Simple.gd
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ func benchmark_avg():
return total / size

func benchmark_vectors():
var b = Transform()
b = b.rotated(Vector3.UP, deg2rad(60))
var b = Transform3D()
b = b.rotated(Vector3.UP, deg_to_rad(60))
b = b.scaled(Vector3(0.5, 0.5, 0.5))

var s: Vector3 = Vector3()
for i in range(1000):
var v = Vector3(i, i, i)
v = b.xform(v)
v = b * (v)
s = s + v

return s
Expand Down
6 changes: 0 additions & 6 deletions harness/benchmarks/godot-project.csproj

This file was deleted.

19 changes: 0 additions & 19 deletions harness/benchmarks/godot-project.sln

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
51 changes: 3 additions & 48 deletions harness/benchmarks/project.godot
Original file line number Diff line number Diff line change
Expand Up @@ -6,60 +6,15 @@
; [section] ; section goes between []
; param=value ; assign values to parameters

config_version=4

_global_script_classes=[ {
"base": "Reference",
"class": "Benchmark",
"language": "GDScript",
"path": "res://scripts/Benchmark.gd"
}, {
"base": "Reference",
"class": "Benchmarks",
"language": "GDScript",
"path": "res://scripts/Benchmarks.gd"
}, {
"base": "Reference",
"class": "Language",
"language": "GDScript",
"path": "res://scripts/Language.gd"
}, {
"base": "Reference",
"class": "Report",
"language": "GDScript",
"path": "res://scripts/Report.gd"
}, {
"base": "Reference",
"class": "Stats",
"language": "GDScript",
"path": "res://scripts/Stats.gd"
}, {
"base": "Object",
"class": "godot_benchmark_Memory",
"language": "Kotlin",
"path": "res://src/main/kotlin/godot/benchmark/Memory.kt"
}, {
"base": "Object",
"class": "godot_benchmark_Simple",
"language": "Kotlin",
"path": "res://src/main/kotlin/godot/benchmark/Simple.kt"
} ]
_global_script_class_icons={
"Benchmark": "",
"Benchmarks": "",
"Language": "",
"Report": "",
"Stats": "",
"godot_benchmark_Memory": "",
"godot_benchmark_Simple": ""
}
config_version=5

[application]

config/name="godot-project"
run/main_scene="res://Benchmarks.tscn"
config/features=PackedStringArray("4.1")
config/icon="res://icon.png"

[rendering]

environment/default_environment="res://default_env.tres"
environment/defaults/default_environment="res://default_env.tres"
2 changes: 1 addition & 1 deletion harness/benchmarks/scripts/Benchmark.gd
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
extends Reference
extends RefCounted
class_name Benchmark

var instance: Object
Expand Down
2 changes: 1 addition & 1 deletion harness/benchmarks/scripts/Benchmarks.gd
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
extends Reference
extends RefCounted
class_name Benchmarks

static func create(langs: Array, name: String) -> Array:
Expand Down
2 changes: 1 addition & 1 deletion harness/benchmarks/scripts/Language.gd
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
extends Reference
extends RefCounted
class_name Language

var name: String
Expand Down
22 changes: 10 additions & 12 deletions harness/benchmarks/scripts/Main.gd
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,10 @@ var classes = [
var languages = [
Language.new("GDScript", "gd", "res://gd/", false),
Language.new("Typed GDScript", "gd", "res://typed_gd/", false),
Language.new("Kotlin", "kt", "res://src/main/kotlin/godot/benchmark/", true),
Language.new("C# Mono", "cs", "res://csharp/", true)
Language.new("Kotlin", "gdj", "res://gdj/godot/benchmark/", true)
]

func _init():
func _initialize ():
var args: Dictionary = __parse_args()
print("Parsed arguments: %s" % str(args))

Expand All @@ -26,7 +25,7 @@ func _init():
if args.has("commit"):
commit = args.commit
else:
commit = str(OS.get_datetime().hash())
commit = str(Time.get_datetime_dict_from_system().hash())

var report = Report.new(commit)

Expand All @@ -44,7 +43,7 @@ func _init():
print("Benchmark tests are over!")
__save_report(report)

func _idle(delta):
func _process (delta):
return true


Expand All @@ -62,7 +61,7 @@ func __run_benchmark(benchmark: Benchmark, report: Report):


func __do_run(iteration: int, benchmark: Benchmark, stats: Stats, is_warmup: bool):
var start: float = OS.get_ticks_usec()
var start: float = Time.get_ticks_usec()
##Loop is costly in GDScropt so to avoid measure the execution time of it, we manually execute the benchmark 30 times.
##Godot doesnt' measure time with enough precision so we have to execute the benchmark multiple times to get more than a 1 micro second.
benchmark.exec()
Expand Down Expand Up @@ -95,18 +94,17 @@ func __do_run(iteration: int, benchmark: Benchmark, stats: Stats, is_warmup: boo
benchmark.exec()
benchmark.exec()
benchmark.exec()
var duration: float = OS.get_ticks_usec() - start
var duration: float = Time.get_ticks_usec() - start
if not is_warmup:
stats.add(duration/30)
#print("[iteration=%d,run=%d] %dus" % [iteration, run, duration])

func __save_report(report: Report):
var f = File.new()
var path = "res://build/benchmark-results.json"
var path = "res://benchmark-results.json"
var file := FileAccess.open(path, FileAccess.WRITE)
print("Writing results at: %s" % path)
f.open(path, File.WRITE_READ)
f.store_string(report.to_json())
f.close()
file.store_string(report.to_json())
file.close()

func __parse_args() -> Dictionary:
var arguments = {}
Expand Down
6 changes: 3 additions & 3 deletions harness/benchmarks/scripts/Report.gd
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
extends Reference
extends RefCounted
class_name Report

var data = {}
Expand All @@ -9,7 +9,7 @@ func _init(commit):

func add(benchmark, results):
var name = benchmark.name
var lang = benchmark.lang
var lang = benchmark.lang.name
if not data.has(name):
data[name] = {}

Expand All @@ -19,4 +19,4 @@ func to_json():
var json = {}
json["commit"] = self.commit
json["data"]= self.data
return JSON.print(json)
return JSON.stringify(json, "\t")
2 changes: 1 addition & 1 deletion harness/benchmarks/scripts/Stats.gd
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
extends Reference
extends RefCounted
class_name Stats

const SEC_IN_USEC = 1000000.0
Expand Down
16 changes: 7 additions & 9 deletions harness/benchmarks/settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,24 @@ rootProject.name = "godot-kotlin-benchmarks"

includeBuild("../../kt/api-generator") {
dependencySubstitution {
substitute(module("com.utopia-rise:api-generator")).with(project(":"))
substitute(module("com.utopia-rise:api-generator")).using(project(":"))
}
}
includeBuild("../../kt") {
dependencySubstitution {
substitute(module("com.utopia-rise:godot-gradle-plugin")).with(project(":godot-gradle-plugin"))
substitute(module("com.utopia-rise:godot-annotation-processor")).with(project(":godot-annotation-processor"))
substitute(module("com.utopia-rise:godot-runtime")).with(project(":godot-runtime"))
substitute(module("com.utopia-rise:godot-library")).with(project(":godot-library"))
substitute(module("com.utopia-rise:godot-bootstrap")).with(project(":godot-bootstrap"))
substitute(module("com.utopia-rise:godot-kotlin-compiler-plugin-common")).with(project(":godot-kotlin-compiler-plugin-common"))
substitute(module("com.utopia-rise:godot-kotlin-compiler-plugin")).with(project(":godot-kotlin-compiler-plugin"))
substitute(module("com.utopia-rise:godot-kotlin-entry-generator")).with(project(":godot-kotlin-entry-generator"))
substitute(module("com.utopia-rise:godot-gradle-plugin")).using(project(":godot-gradle-plugin"))
substitute(module("com.utopia-rise:godot-library")).using(project(":godot-library"))
substitute(module("com.utopia-rise:godot-kotlin-symbol-processor")).using(project(":godot-kotlin-symbol-processor"))
substitute(module("com.utopia-rise:godot-entry-generator")).using(project(":godot-entry-generator"))
}
}


pluginManagement {
repositories {
mavenCentral()
gradlePluginPortal()
google()
}
resolutionStrategy.eachPlugin {
if (requested.id.id == "com.utopia-rise.godot-kotlin-jvm") {
Expand Down
Loading