Created
February 21, 2024 04:47
-
-
Save Shilo/340599c74d8d877825ddbf3b4db24321 to your computer and use it in GitHub Desktop.
Simple Benchmark methods in Godot.
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
public static void Benchmark(Action callable, string tag = null) | |
{ | |
var start = Time.GetTicksMsec(); | |
callable(); | |
var duration = Time.GetTicksMsec() - start; | |
if (tag != null) | |
GD.PrintT(tag, duration); | |
else | |
GD.Print(duration); | |
} |
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
func benchmark(callable: Callable, tag: String = null): | |
var start: int = Time.get_ticks_msec() | |
callable.call() | |
var duration: int = Time.get_ticks_msec() - start | |
if tag: | |
printt(tag, duration) | |
else: | |
print(duration) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment