UniTask performance issue compared to Unity coroutines #662
SudarshanShetty1796
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
I’ve implemented a central scheduler-like functionality for games to avoid unnecessary repetitive code when adding coroutines or UniTasks.
Initially, my scheduler was internally using coroutines, but later I came across the UniTask package, so I ported the coroutines to use UniTasks.
Now, the issue is—after profiling both implementations to check runtime performance and GC allocations—the results show that UniTask is significantly more expensive than coroutines in terms of both CPU usage and GC allocations!
I’m attaching both the Coroutine-based and UniTask-based scheduler implementations, along with screenshots from the profiler.
The setup is simple: I’m just spawning 100 instances of the scheduler like this.
So, can someone tell me if I’m doing something wrong, or clarify how UniTask is supposed to be more efficient than coroutines? Or is there no comparison between the two, and it's just another plugin?
With Coroutine:

With UniTask

Coroutine scheduler: Coroutine-Scheduler.zip
UniTask scheduler: UniTask-Scheduler.zip
Beta Was this translation helpful? Give feedback.
All reactions