harvard-lts/fits — pull request #7 by mistydemeo (2013-09-02 22:22:03+00:00)
Title: Avoid instantiating Fits class until necessary

The Fits class is relatively slow to load, and depending on the speed of the computer can take between 0.5s and 1s to instantiate. (It looks like most of this is happening in DROID's signature loading - upgrading to a new version of DROID would probably cut down a lot of startup time.)

On the other hand, this class isn't actually necessary until FITS needs to start processing. It looks like it was only being instantiated earlier for the sake of the printHelp() method, which didn't actually need access to the internal state of the Fits class.

This converts printHelp into a static function, then moves instantiation of the Fits class as late as possible. This ensures that the Fits class doesn't get instantiated when it's not being used, for instance if FITS is exiting without running any tools via the -h help option, or due to invalid commandline usage.

The difference is quite significant. With JVM lag removed (e.g., via a Nailgun server), `fits -h` can take as long as 10 seconds(!) to display its help text, with typical times at between 0.5s and 1s. With this patch, typical time to display help text is 0.08s - providing a much better user experience.