# Burst static functions VS Inline in burst code

I have a helper script for common math functions I use. This is static and already burst compiled.
I did not see a huge increase in performance, but that’s fine since I will convert the majority of code into jobs anyways.

The helper functions will be used in burstcompiled jobs. I wonder if I should keep these functions the way they are, or use `MethodImplOptions.AggressiveInlining` instead, like in the math class, so burst can optimize the whole job. I originally used return float3, which was incompatible with burst, but it’s easy to get return back in there

Any thoughts on this? (if you have tips to optimize stuff like this I’m also definitely open for it, first time working with jobs and burst)

Current code example:

``````[BurstCompile]
public static void GetPointOnQuadraticBezierCurve(in float3 point1, in float3 controlPoint3, in float3 point2, float t, out float3 result)
{
// Calculate the position on the curve based on the blending factors
result = ((1 - t) * (1 - t) * point1)
+ (2 * (float)(1 - t) * t * controlPoint3)
+ (t * t * point2);
}
``````

(Extra: Would there be a benefit if I use float3x4 instead of 4 float3 values if my job needs 4 float3 values?)

Burst can do that regardless. If you aren’t seeing a big increase in performance with that Bursted static method, my guess is that there is some non-Bursted stuff that is still fairly expensive, and that once you move that into a job (or even just a bigger static method) things will go a lot faster.

Not float3x4, but a float4x3 can be faster if used in the right situations. Make sure to profile. https://github.com/Dreaming381/Latios-Framework/blob/v0.6.6/Core/Math/simdFloat3.cs

Thanks!

First point: is there a reason the math library doesn’t burst compile if this the case?
Just curious about the inner workings. Everything is now jobified and since I complete the job in Late Update I barely touch the main thread :o

Maybe I’ll run a test tomorrow and see if I can measure any difference.

And thanks for the second recommendation! I’ll check it out

Burst has a dependency on Mathematics and not the other way around. Mathematics doesn’t know about Burst. Same for engine code. Engine code can’t use Burst because Burst is a package.

1 Like

I tried inlining some commonly used (relatively simple) static methods and I think performance is slightly faster this way. Will test more later and if needed file a bug report

@xoofx Sorry for the ping, but we talked a bit at the Blitz Day.
Would love to hear if you know of any preference from a performance standpoint of using inlining vs bursted static methods.

Extra question:
When returning an int in a bursted method (not inlined), would it be preferable to use return or out float? This, because I saw `CantVectorizeInstructionReturnType`, as well as return not being on HPC# overview | Burst | 1.8.17