ddg-screen-diff
ddg-screen-diff copied to clipboard
Basic command response quite slow
Commands such as ddg-screen-diff --help take a noticable time to respond - can anyone else confirm this?
What kind of response time are you getting? I'm getting the following on my machine:
$ time ddg-screen-diff --help
Usage: ddg-screen-diff [--version] [--help] <command> ... [options]
Commands:
search Create a screenshot against a search query
path Create a screenshot against an arbitrary path
ia Create a screenshot against an IA
group Create a screenshot against a pre-defined group
Options:
--version Show version number [boolean]
-h, --help Show help [boolean]
real 0m0.302s
user 0m0.296s
sys 0m0.016s
@andrey-p Seems about right.
For time python --help I get:

For time ddg-screen-diff --help I get:

See what I mean by the delay? For something simple like --help I would expect the response to be almost instantaneous.
All right yeah, I see what you mean. I think it's down to the way the modules are put together. The entry point module requires the main module, which requires all the other ddg-screen-diff modules, which require all the dependencies down to the selenium-webdriver, which is a beast.
It would be possible to delay the require() calls until the modules are actually needed, which should speed things up a bit.
Hope you don't mind if I mark this issue as low priority - I'd love it if someone dived in and fixed it, but there's other issues with the tool I need to address beforehand.
@andrey-p Not at all!
Yeah, it seems a bit overkill to be loading everything just for simple calls.
@andrey-p @GuiltyDolphin Can you please provide some insight into the cause of this issue? I'd love to fix this one :smile:
Hey @sahildua2305 - I added a rough description in my last comment, but in a bit more detail:
The main entry point for the program is: https://github.com/duckduckgo/ddg-screen-diff/blob/master/lib/run.js.
There's a lot of require()s at the top of the file, which means a lot of stuff is done at startup. Realistically, we don't need most of them until after L23. L23 is where the program checks the command line input and bails if, say, the --help argument was passed.