Optimizing Bookmarkr’s performance
We cannot optimize what is already perfect, can we?
Just kidding. Of course we can! There is always room for improvement.
Let’s see some of the quick wins that we can apply to enhance the performance of our beloved CLI application.
Looking at the handler method of the ExportCommand
class (namely, OnExportCommand
), we can see that it already leverages async operations. This is a great start and is actually one of the techniques we described earlier.
However, the handler method can be optimized. To illustrate this, let’s create a copy of the ExportCommand
class and name it ExportCommandOptimized
. Let’s copy the code from the ExportCommand
as is, and we will optimize it in a moment.
The reason we are creating a copy of the original class rather than directly optimizing it is so that we can add a benchmark method for the optimized version and compare it with the original one.
In the handler method of the ExportCommandOptimized...