Programming-Language-Benchmarks icon indicating copy to clipboard operation
Programming-Language-Benchmarks copied to clipboard

`1.dart`: fix `Stream` and `yield` usage

Open gmpassos opened this issue 3 years ago • 3 comments

The previous code was using yield in a wrong (or outdated) form, creating unnecessary Future + lambda and unnecessary use of await.

gmpassos avatar Sep 01 '22 18:09 gmpassos

Without this fix the Dart benchmark status is timeout, BTW.

gmpassos avatar Sep 15 '22 19:09 gmpassos

See my comment on line 18, don't over-optimize it.

Without this fix the Dart benchmark status is timeout, BTW.

What perf gain did u see? I see negligible number difference with this change locally

hanabi1224 avatar Sep 16 '22 06:09 hanabi1224

I can change to yield await Future.value(i);, since it's almost the same execution time.

The main point here is that this is not an over optimization. yield I; is the simpler version, and return a Future.value here is the unnecessary optimization. In Dart 2.18 the compiler won't schedule a micro task if you return a Future.value, in other words it will have the exact same behavior of yield I;.

Let me know what approach do you prefer. Regards.

gmpassos avatar Sep 19 '22 18:09 gmpassos