Advanced Search
Search Results
12 total results found
Introduction
Last update : February 2023 As many of you may already know, Udon can be pretty slow, but I was curious to know what really slows it down, so I made a world called "Udon Benchmark" to benchmark it, the world can be found here https://vrchat.com/home/world/wrl...
U# vs C#
U# is noticeably slower than regular C#, to benchmark it I decided to execute two scripts in U# and C#, one calculates the n-th Fibonacci number, the second one generates a maze. To make those tests a bit fairer, I disable the C# compiler optimization, since ...
For loop
For this test I was curious to see how well Udon executes for-loops, and the results I got were really unexpected. I executed two methods Benchmark1 and Benchmark2 and compared their execution time. public override void Benchmark1() { int number = 0; fo...
Recursive vs iterative
For this test I was curious to see how well Udon executes recursive methods, in the previous test I already compared the execution time of recursive functions in U# and C#, but here I wanted to compare the execution time between a recursive function and an ite...
Builtin functions vs calculating something manually
Let's say you want to calculate the distance between two vectors. Some of you would probably write something like this : distance = Vector3.Distance(a,b); Others might write something like this (which is how Unity implemented the Distance method) : float n...
Function overhead test
For this test I was curious to see the overhead of a function call I executed two methods Benchmark1 and Benchmark2 and compared their execution time. private void Func() { int j = 0; } public override void Benchmark1() { for (int i = 0; i < 50000;...
GetComponent<>()
Many of you may already know that calling GetComponent is pretty expensive in Unity. But how expensive is it in Udon? Let's see! I executed two methods Benchmark1 and Benchmark2 and compared their execution time. public override void Benchmark1() { Labyr...
Calling methods from a separate script
Let's say you have script A that accesses a method from script B. Would it be more performant to merge script A and B together? Let's see! public Fibonacci FibonacciInstance; [RecursiveMethod] private int FibonacciRecursive(int n) { if (n <= 0) r...
Caching Networking.LocalPlayer
Some programmers like to cache the local player for later use, for instance by adding a private member private VRCPlayerAPI _localPLayer; then setting the local player _localPlayer = Networking.LocalPlayer; in Start() Let's see how it affects the performance ...
The "ref" keyword
U# now supports the "ref" keyword, which is really cool! For those who don't know what the "ref" keyword does, I'll link the C# documentation here : https://learn.microsoft.com/en-US/dotnet/csharp/language-reference/keywords/ref But does it affect the perform...
Other Udon optimization tips
Update events, like Update() or FixedUpdate() It is generally not recommended to execute code every frame, the performance impact can be quite noticeable. FixedUpdate() is even worse because the refresh rate is generally higher. It is actually locked to you...
400 Update() calls vs one Update() call iterating 400 times
What would be more performant in Udon? 400 GameObjects executing some code every frame with an Update event : public class EveryFrame : UdonSharpBehaviour { void Update() { transform.position = Vector3.zero; } } One GameObject with one Upd...