vadimdemedes / ronin

Toolkit for killer CLI applications
http://vdemedes.github.io/ronin
MIT License
299 stars 15 forks source link

Lazy load commands #7

Closed robhrt7 closed 9 years ago

robhrt7 commented 9 years ago

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.

vadimdemedes commented 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.

vadimdemedes commented 9 years ago

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.

robhrt7 commented 9 years ago

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.

vadimdemedes commented 9 years ago

What loading time are you experiencing?

robhrt7 commented 9 years ago

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

vadimdemedes commented 9 years ago

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?

robhrt7 commented 9 years ago

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.

vadimdemedes commented 9 years ago

Tested myself, discovered slow delay too. Will fix in next releases.

robhrt7 commented 9 years ago

Thank you.

medeeiros commented 9 years ago

+1