firebase / firebase-unity-sdk

The Firebase SDK for Unity
http://firebase.google.com
Apache License 2.0
220 stars 35 forks source link

[FR] Make `Firebase.Analytics.Parameter` instances reusable. #548

Open IoannisFMG opened 1 year ago

IoannisFMG commented 1 year ago

Feature proposal

Right now if you want to send an event at some point in your game, you have to instantiate the Parameter class once per parameter. The only way you can create a Parameter is via its constructor. There are no getters/setters and its fields are marked private (rightfully so) thus making it immutable once created. Some events might require a considerable amount of parameters to be sent over to the servers. For example, a single ad_revenue event requires 8 parameters. Thus 8 allocations, plus any more needed to gather the data (if applicable).

Allocations are harmful when it comes to code performance and they it's wise if they are minimized. If Parameter class instances were reusable, the overhead of sending an event could be minimal, improving performance both in CPU and RAM (allocations/garbage collection).

I'd like to know if there is a way to do this right now. There seems to be none as far as I know. If there is none, is there any way we can have this in a future update of the sdk?

Thank you!

google-oss-bot commented 1 year ago

I found a few problems with this issue:

snappedToGrid commented 1 year ago

👍

Yes. It's a bummer to instantiate so many parameters and sometimes so frequently.