Skip to main content

Performance

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

When to use Firebase TypeScript

Firebase TypeScript is perfect if you want a consistent, readable, maintainable and shareable class pattern to use with your Firestore database. As the Firestore database does not provide any scheme your code is the only instance defining your scheme. So using this sort of class pattern is useful to reduce bugs and improve your product stability for the end user.

When not to use Firebase TypeScript

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

Firebase TypeScript 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. Those performance impacts are only for writing and reading documents and not for working with the documents.

TestRunsAverage timeTotal time
Native / no classes1< 1ms< 1ms
DocumentClass write1< 1ms< 1ms
DocumentClass read1< 1ms< 1ms
Native / no classes1001ms0.001ms
DocumentClass write1001ms0.001ms
DocumentClass read1001ms0.001ms
Native / no classes10000.001ms1ms
DocumentClass write10000.003ms3ms
DocumentClass read10000.011ms11ms
DocumentClass async write10000.002ms3ms
DocumentClass async read10000.002ms11ms
info

In a future release we plan to provide a LightweightDocumentClass and LightweightDocumentMap with less features than DocumentClass and DocumentMap but near native performance.