Move Timing out of src/test/

Required for Maven...

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
ObjectIndex: support PluginIndex better

We used to require overriding the add() method for only one reason:
the type by which the objects are indexed in PluginIndex are not
obtained by getClass(), but by getPluginType().

This suggests that the base class actually needs a more flexible way
to obtain the types by which to index, so let's do that instead.

This will help with the upcoming performance enhancements which will
bypass the add() method completely for SortedObjectIndex' addAll().

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Try to speed up the SortedObjectIndex further

Rather than adding things blindly to several typed lists which are all
supported to be sorted already, only to sort them again in the end,
let's

- sort the elements to be added

- make sub-lists of the sorted list for the individual typed lists

- merge the sorted lists in O(n)

instead.

While at it, we should not iterate the elements of HashSets with
supposedly immutable contents over and over and over again. Let's make
performant arrays from them as soon as we generated the sets.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Speed up loading the services by publishing the ServicesLoadedEvent lazily

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
DefaultEventBus: avoid publishing events nobody is interested in

The AWT EventQueue is really slow: EventQueue.invokeAndWait() can take
up to 30x as long as creating a new thread and starting it on the
provided Runnable.

If there is not even a subscriber to the event we are about to send,
let's just not bother.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
TO-UNDO: timings

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
TO-UNDO: timing Context

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>