Skip to main content

Performance

Using Definable will obviously make a small performance impact. This is why we made a small information about when to use Definable and when to better not use it as well as some metrics to let you decide better.

When to use Definable

Definable is perfect if you want a consistent, readable, maintainable and shareable class pattern to use with JSON data, especially when being used with storage solutions or databases. Using this sort of class pattern is useful to reduce bugs and improve your product stability for the end user.

When not to use Definable

As Definable has some performance impact especially when using a huge amount of classes at the same time using it in heavy tasks that are reading or writing heavy amount of classes (> 10000 or more) isn't ideal.

Definable is also not ideal for applications where every 0,01ms counts - for example in Games.

Performance metrics

To provide some data, we have compared "native performance" (using plain JavaScript Objects) with the usage of DocumentClass. The DocumentClass included one DocumentMap.

  • Native / no classes: this tests used no class model at all. You need to consider that you probably want to use classes and create a manual serialization that may slow down execution time.
  • DocumentClass write: this tests tested the latency added when writing your document to the Firestore database.
  • DocumentClass read: this tests tested the latency added when reading your document from the Firestore database.
  • DocumentClass async write: this tests tested the latency added when editing your document locally, displaying it to the user and writing your document to the Firestore database after displayed to the user.
  • DocumentClass async read: this tests tested the latency added when knowing the document exist, displaying the default values to the user and then reading the document class information from the firestore. Note that this is a scenario you would probably not find in most applications.
note

Keep in mind that the result vary depending on the system, class structure and other factors.

TestRunsAverage timeTotal time
No classes1< 1ms< 1ms
Definable write1< 1ms< 1ms
Definable read1< 1ms< 1ms
Native class write1< 1ms< 1ms
Native class read1< 1ms< 1ms
No classes1001ms0.001ms
Definable write1001ms0.001ms
Definable read1001ms0.001ms
Native class write1001ms0.001ms
Native class read1001ms0.001ms
No classes10001ms0.001ms
Definable write10003ms0.003ms
Definable read10003ms0.003ms
Native class write10002ms0.002ms
Native class read10002ms0.002ms