leancodepl / patrol

Flutter-first UI testing framework. Ready for action!
https://patrol.leancode.co
Apache License 2.0
863 stars 127 forks source link

Slow code on critical path of CLI startup #1966

Open bartekpacia opened 9 months ago

bartekpacia commented 9 months ago

This code:

https://github.com/leancodepl/patrol/blob/06a50416a8874888347b14a7c5cb6d45562eeae7/packages/patrol_cli/lib/src/analytics/analytics.dart#L37-L46

is executed on the critical path of Patrol CLI startup. The problem is that it calls flutter --version:

https://github.com/leancodepl/patrol/blob/06a50416a8874888347b14a7c5cb6d45562eeae7/packages/patrol_cli/lib/src/analytics/analytics.dart#L186-L191

and it's really slow (~2-3 seconds on my M1 MBA).

We should find a way to not block on it, because it's only needed for analytics. This is especially annoying when trying to use tab completion in shell – it makes completion way to slow, practically unusable.

piotruela commented 9 months ago

@bartekpacia I tried to reproduce this problem but it's fast on my machine. I measured execution time of flutter --version and it's around 100ms. No matter if it's called by patrol_cli or typed by me in the console

bartekpacia commented 9 months ago

Hmm, I must've had weaker network connection then. Still, this is something to be fixed, but maybe not with P1 but P2.

You should be able to reproduce this by adding some artificial timeout to _getFlutterVersion.