gmcgath/fits-mcgath — pull request #1 by mistydemeo (2013-08-23 18:28:45+00:00)
Title: Avoid instantiating Fits class until necessary

The Fits class is still relatively slow to load, and depending on the speed of the computer can take between 0.5s and 1s to instantiate.

On the other hand, this class isn't actually necessary until FITS needs to start processing. 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.

I'll be submitting a separate request to separate out the FITS launcher scripts a bit to make it easier to kick off a Nailgun server to improve FITS startup times in all usecases.