[dart tool] `dart run ` is significantly slower than `dart ` command

Running dart run <dart-file> is much slower than running dart <dart-file>. This is inconsistent with the dart tool doc and the issue was raised on reddit. It appears the dart run version is doing much more work before starting the app. See comparisons below:


void main() {
$ time dart run example/hello.dart

real    0m0.630s
user    0m0.432s
sys     0m0.134s
$ time dart example/hello.dart

real    0m0.190s
user    0m0.188s
sys     0m0.073s
$ time pub run example/hello.dart

real    0m0.360s
user    0m0.417s
sys     0m0.127s

Dart SDK version: 2.11.0-240.0.dev (dev) (Tue Oct 20 16:27:23 2020 -0700) on “macos_x64”

Author: Fantashit

1 thought on “[dart tool] `dart run ` is significantly slower than `dart ` command

  1. Thanks @bkonyi. Makes sense and aligns with observation, but we should at least make sure our docs correctly reflect this to avoid developer confusion. Currently the docs at dart: The Dart command-line tool imply the two are identical.

    dart <DART_FILE> : Runs a Dart program, just like dart run.

Comments are closed.