Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Guidelines / solution to run compiled version #60

Open
vkammerer opened this issue Sep 13, 2021 · 1 comment
Open

Guidelines / solution to run compiled version #60

vkammerer opened this issue Sep 13, 2021 · 1 comment

Comments

@vkammerer
Copy link
Collaborator

Is your feature request related to a problem? Please describe.
The current execution of flutter pub run import_sorter:main has a slow start due to the Dart VM initialisation. While it is acceptable if it is ran infrequently (like as a GIT commit hook for example), it is a lot more critical when running frequently (like every time a file is saved for example).

Describe the solution you'd like

  • Give users guidelines to use the natively compiled version of the library rather that its Dart version
  • OR find a way to distribute the compiled versions

Describe alternatives you've considered
I have tested the execution time of this library for three different versions:

Results:

  • 1 was the slowest, with an initialisation time of about 1 to 2 seconds on a i9 2019 Macbook Pro 16'.
  • 2 was faster, maybe twice faster.
  • 3 was the fastest, almost instantaneous

Additional context
The benefits of running a compiled version are also explained in https://dart.dev/tutorials/server/get-started#6-compile-for-production.

This is what I've done to get a nice experience using this lib:

  1. Compile to native code
dart compile exe bin/main.dart -o bin/import_sorter
  1. Add bin path to PATH
  2. Use lib in VSCode with https://marketplace.visualstudio.com/items?itemName=emeraldwalk.RunOnSave
    I've set it up with the following settings:
  "emeraldwalk.runonsave": {
    "commands": [
      {
        "match": "\\.dart$",
        "cmd": "import_sorter ${file}"
      }
    ]
  }

Now every time I save a file in my IDE, the imports are organised instantaneously! This makes it a lot more enjoyable.

@gleich
Copy link
Member

gleich commented Dec 7, 2021

See #63

@gleich gleich closed this as completed Dec 7, 2021
@gleich gleich reopened this Dec 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants