Closed robhrt7 closed 9 years ago
Thanks for suggestion, I will address this issue. I am currently refactoring Ronin to make it more flexible and make codebase more clean.
Refactored and released Ronin v0.3.0. I thought about this issue and decided that this problem does not really exist. I've never noticed slow initialization time, despite many require() statements. If you can provide me with an example of slow init time because of many require(), I will reopen the issue for sure.
Em... Well, we will just fork it then. When we will open our tool publicly, I will show the example.
But really, if you're doing semi-complex CLI tool that covers few different use cases with non reusable dependencies, you will always get really unpleasant loading time.
What loading time are you experiencing?
I've done some perf tests, currently our CLI with 9 commands, on my 2014 MB Air (1,7 GHz Intel Core i7) takes 1.2-1.4
seconds to initialize.
If I remove all other commands, and leave only one that I call, initialization takes 0.5
seconds. I'm expecting commands to be initialized as fast as possible, and 0.5
seconds is pretty okay, comparing with 1.5
.
Perf measurement triggered before Ronin program.run()
till the start of command code execution.
cc @igord
wow, there must be something wrong about your setup. I have a Ronin-based CLI tool with approx. 15-20 commands and it starts up instantly. Do you use auto-update functionality in your program?
There is nothing wrong with my setup, it's just a set of dependencies that takes time to initialize.
Here's an example, which takes 400-500 ms to initialize without any command code https://github.com/operatino/test-ronin. I listed there not full list of our deps, so you could imagine what happens if other commands require different deps.
Tested myself, discovered slow delay too. Will fix in next releases.
Thank you.
+1
Currently, during the cli tool initialization, Ronin is loaded all commands and their dependencies. If the CLI tools have a lot of commands, which need different dependencies, we have very long initialization time.
Solution: During the execution of specified command, load only needed dependencies.