Skip to content

Commit c16626e

Browse files
committed
Update bunnymark to new benchmarks
1 parent 7d19352 commit c16626e

File tree

5 files changed

+55
-61
lines changed

5 files changed

+55
-61
lines changed

harness/bunnymark/src/main/kotlin/godot/benchmark/bunnymark/BunnymarkV1DrawTexture.kt

+8-13
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,15 @@ import godot.Node2D
44
import godot.RandomNumberGenerator
55
import godot.ResourceLoader
66
import godot.Texture2D
7-
import godot.annotation.RegisterClass
8-
import godot.annotation.RegisterFunction
9-
import godot.annotation.RegisterSignal
7+
import godot.annotation.GodotMember
8+
import godot.annotation.GodotScript
109
import godot.core.Vector2
11-
import godot.signals.signal
10+
import godot.core.signal1
1211

13-
@RegisterClass("BunnymarkV1DrawTexture")
12+
@GodotScript("BunnymarkV1DrawTexture")
1413
class BunnymarkV1DrawTexture : Node2D() {
1514

16-
@RegisterSignal
17-
val benchmarkFinished by signal<Int>("bunnyCount")
15+
val benchmarkFinished by signal1<Int>("bunnyCount")
1816

1917
data class Bunny(var position: Vector2, var speed: Vector2)
2018

@@ -25,19 +23,16 @@ class BunnymarkV1DrawTexture : Node2D() {
2523

2624
private lateinit var screenSize: Vector2
2725

28-
@RegisterFunction
2926
override fun _ready() {
3027
randomNumberGenerator.randomize()
3128
}
3229

33-
@RegisterFunction
3430
override fun _draw() {
3531
for (bunny in bunnies) {
3632
drawTexture(bunnyTexture, bunny.position)
3733
}
3834
}
3935

40-
@RegisterFunction
4136
override fun _process(delta: Double) {
4237
screenSize = getViewportRect().size
4338

@@ -80,7 +75,7 @@ class BunnymarkV1DrawTexture : Node2D() {
8075
queueRedraw()
8176
}
8277

83-
@RegisterFunction
78+
@GodotMember
8479
fun addBunny() {
8580
bunnies.add(
8681
Bunny(
@@ -90,13 +85,13 @@ class BunnymarkV1DrawTexture : Node2D() {
9085
)
9186
}
9287

93-
@RegisterFunction
88+
@GodotMember
9489
fun removeBunny() {
9590
if (bunnies.size == 0) return
9691
bunnies.removeAt(bunnies.size - 1)
9792
}
9893

99-
@RegisterFunction
94+
@GodotMember
10095
fun finish() {
10196
benchmarkFinished.emit(bunnies.size)
10297
}

harness/bunnymark/src/main/kotlin/godot/benchmark/bunnymark/BunnymarkV1Sprites.kt

+16-15
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
11
package godot.benchmark.bunnymark
22

3-
import godot.core.*
4-
import godot.*
5-
import godot.annotation.RegisterClass
6-
import godot.annotation.RegisterFunction
7-
import godot.annotation.RegisterSignal
8-
import godot.signals.signal
9-
10-
@RegisterClass("BunnymarkV1Sprites")
3+
import godot.Node2D
4+
import godot.RandomNumberGenerator
5+
import godot.ResourceLoader
6+
import godot.Sprite2D
7+
import godot.Texture2D
8+
import godot.annotation.GodotMember
9+
import godot.annotation.GodotScript
10+
import godot.core.Vector2
11+
import godot.core.signal1
12+
13+
14+
@GodotScript("BunnymarkV1Sprites")
1115
class BunnymarkV1Sprites : Node2D() {
1216

13-
@RegisterSignal
14-
val benchmarkFinished by signal<Int>("bunnyCount")
17+
val benchmarkFinished by signal1<Int>("bunnyCount")
1518

1619
private data class Bunny(var sprite: Sprite2D, var speed: Vector2)
1720

@@ -22,12 +25,10 @@ class BunnymarkV1Sprites : Node2D() {
2225

2326
private lateinit var screenSize: Vector2
2427

25-
@RegisterFunction
2628
override fun _ready() {
2729
randomNumberGenerator.randomize()
2830
}
2931

30-
@RegisterFunction
3132
override fun _process(delta: Double) {
3233
screenSize = getViewportRect().size
3334

@@ -69,7 +70,7 @@ class BunnymarkV1Sprites : Node2D() {
6970
}
7071
}
7172

72-
@RegisterFunction
73+
@GodotMember
7374
fun addBunny() {
7475
val bunny = Sprite2D()
7576
bunny.texture = bunnyTexture
@@ -83,7 +84,7 @@ class BunnymarkV1Sprites : Node2D() {
8384
)
8485
}
8586

86-
@RegisterFunction
87+
@GodotMember
8788
fun removeBunny() {
8889
if (bunnies.size == 0) return
8990
val bunny = bunnies[bunnies.size - 1]
@@ -92,7 +93,7 @@ class BunnymarkV1Sprites : Node2D() {
9293
bunny.sprite.queueFree()
9394
}
9495

95-
@RegisterFunction
96+
@GodotMember
9697
fun finish() {
9798
benchmarkFinished.emit(bunnies.size)
9899
}

harness/bunnymark/src/main/kotlin/godot/benchmark/bunnymark/BunnymarkV2.kt

+16-15
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
11
package godot.benchmark.bunnymark
22

3-
import godot.core.*
4-
import godot.*
5-
import godot.annotation.RegisterClass
6-
import godot.annotation.RegisterFunction
7-
import godot.annotation.RegisterSignal
8-
import godot.signals.signal
9-
10-
@RegisterClass("BunnymarkV2")
3+
import godot.Label
4+
import godot.Node2D
5+
import godot.RandomNumberGenerator
6+
import godot.ResourceLoader
7+
import godot.Sprite2D
8+
import godot.Texture2D
9+
import godot.annotation.GodotMember
10+
import godot.annotation.GodotScript
11+
import godot.core.Vector2
12+
import godot.core.signal1
13+
14+
@GodotScript("BunnymarkV2")
1115
class BunnymarkV2 : Node2D() {
1216

13-
@RegisterSignal
14-
val benchmarkFinished by signal<Int>("bunnyCount")
17+
val benchmarkFinished by signal1<Int>("bunnyCount")
1518

1619
private val gravity = 500
1720
private val bunnySpeeds = mutableListOf<Vector2>()
@@ -22,15 +25,13 @@ class BunnymarkV2 : Node2D() {
2225

2326
private lateinit var screenSize: Vector2
2427

25-
@RegisterFunction
2628
override fun _ready() {
2729
randomNumberGenerator.randomize()
2830
addChild(bunnies)
2931
label.setPosition(Vector2(0, 20))
3032
addChild(label)
3133
}
3234

33-
@RegisterFunction
3435
override fun _process(delta: Double) {
3536
screenSize = getViewportRect().size
3637
label.text = "Bunnies: " + bunnies.getChildCount().toString()
@@ -75,7 +76,7 @@ class BunnymarkV2 : Node2D() {
7576
}
7677
}
7778

78-
@RegisterFunction
79+
@GodotMember
7980
fun addBunny() {
8081
val bunny = Sprite2D()
8182
bunny.texture = bunnyTexture
@@ -86,7 +87,7 @@ class BunnymarkV2 : Node2D() {
8687
)
8788
}
8889

89-
@RegisterFunction
90+
@GodotMember
9091
fun removeBunny() {
9192
val childCount = bunnies.getChildCount()
9293
if (childCount == 0) return
@@ -99,7 +100,7 @@ class BunnymarkV2 : Node2D() {
99100
bunnySpeeds.removeAt(childCount.toInt() - 1)
100101
}
101102

102-
@RegisterFunction
103+
@GodotMember
103104
fun finish() {
104105
benchmarkFinished.emit(bunnySpeeds.size)
105106
}

harness/bunnymark/src/main/kotlin/godot/benchmark/bunnymark/BunnymarkV3.kt

+13-13
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
11
package godot.benchmark.bunnymark
22

3-
import godot.*
4-
import godot.annotation.RegisterClass
5-
import godot.annotation.RegisterFunction
6-
import godot.annotation.RegisterSignal
3+
import godot.Label
4+
import godot.Node2D
5+
import godot.RandomNumberGenerator
6+
import godot.ResourceLoader
7+
import godot.Texture2D
8+
import godot.annotation.GodotMember
9+
import godot.annotation.GodotScript
710
import godot.benchmark.bunnymark.v3.Bunny
811
import godot.core.Vector2
9-
import godot.signals.signal
12+
import godot.core.signal1
1013

11-
@RegisterClass("BunnymarkV3")
14+
@GodotScript("BunnymarkV3")
1215
class BunnymarkV3 : Node2D() {
1316

14-
@RegisterSignal
15-
val benchmarkFinished by signal<Int>("bunnyCount")
17+
val benchmarkFinished by signal1<Int>("bunnyCount")
1618

1719
private val randomNumberGenerator = RandomNumberGenerator()
1820
private val bunnyTexture = ResourceLoader.load("res://images/godot_bunny.png") as Texture2D
@@ -21,7 +23,6 @@ class BunnymarkV3 : Node2D() {
2123

2224
private lateinit var screenSize: Vector2
2325

24-
@RegisterFunction
2526
override fun _ready() {
2627
randomNumberGenerator.randomize()
2728
addChild(bunnies)
@@ -30,13 +31,12 @@ class BunnymarkV3 : Node2D() {
3031
addChild(label)
3132
}
3233

33-
@RegisterFunction
3434
override fun _process(delta: Double) {
3535
screenSize = getViewportRect().size
3636
label.text = "Bunnies ${bunnies.getChildCount()}"
3737
}
3838

39-
@RegisterFunction
39+
@GodotMember
4040
fun addBunny() {
4141
val bunny = Bunny()
4242
bunny.texture = bunnyTexture
@@ -45,7 +45,7 @@ class BunnymarkV3 : Node2D() {
4545
bunny.speed = Vector2(randomNumberGenerator.randi() % 200 + 50, randomNumberGenerator.randi() % 200 + 50)
4646
}
4747

48-
@RegisterFunction
48+
@GodotMember
4949
fun removeBunny() {
5050
val childCount = bunnies.getChildCount()
5151
if (childCount != 0) {
@@ -55,7 +55,7 @@ class BunnymarkV3 : Node2D() {
5555
}
5656
}
5757

58-
@RegisterFunction
58+
@GodotMember
5959
fun finish() {
6060
benchmarkFinished.emit(bunnies.getChildCount())
6161
}

harness/bunnymark/src/main/kotlin/godot/benchmark/bunnymark/v3/Bunny.kt

+2-5
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@ package godot.benchmark.bunnymark.v3
22

33
import godot.RandomNumberGenerator
44
import godot.Sprite2D
5-
import godot.annotation.RegisterClass
6-
import godot.annotation.RegisterFunction
5+
import godot.annotation.GodotScript
76
import godot.core.Vector2
87

9-
@RegisterClass
8+
@GodotScript
109
class Bunny : Sprite2D() {
1110

1211
var speed = Vector2()
@@ -15,12 +14,10 @@ class Bunny : Sprite2D() {
1514
private lateinit var screenSize: Vector2
1615
private val randomNumberGenerator = RandomNumberGenerator()
1716

18-
@RegisterFunction
1917
override fun _ready() {
2018
randomNumberGenerator.randomize()
2119
}
2220

23-
@RegisterFunction
2421
override fun _process(delta: Double) {
2522
screenSize = getViewportRect().size
2623
val pos = position

0 commit comments

Comments
 (0)