Skip to content

Configurations

Stéphane Nicolas edited this page May 22, 2016 · 19 revisions

Configuration class

The class toothpick.Configuration allows to change Toothpick internal behaviors.

This wiki page will not detail in much length all possible configurations, we simply invite developers to browse the javadoc of this class to get more details. The documentation is available on maven central and your IDE should let you browse it during edition of java source files.

One word on reflection

Toothpick is completely reflection free. But not by default.

By default Toothpick will use a very limited amount of reflection to:

  • load factories
  • load member injectors

This settings allow to get started faster. Though, for those who are interested in getting a slight performance increase, Toothpick also provides a reflectionFree configuration based on registries to load both factories and injectors. In this more advanced configuration, Toothpick works without using any reflection code at all.

To enable this configuration, developers will have to setup their registries locations correctly for each compile unit as detailed in Registries.

Benchmark of reflection vs registries

On a Nexus 5, running Android 6.0.1, we have benchmarked the following performances when accessing and creating an instance of a Factory.

#of factories Registries Reflection
100 0.6 ms 4 ms
1000 4.6 ms 29.7 ms
51120 102 ms 1130 ms

Thus, Toothpick offers a mechanism to also bypass reflection when creating factories. Reflection is offered as an easy way to configure Toothpick, but applications looking for more speed should use registries.

Links