Ometis Blog

Reload Stats - A New Tool from Ometis - UK's Leading Qlik Consultants

Written by Ometis | Aug 11, 2020 11:58:42 AM

What is Reload Stats?

Ever wondered how long a section of your code took to reload after a change you made? Do you want to know what’s taking so long, so you can tinker with it to make it go faster? Well, Reload Stats is the right tool for you!

Reload Stats is a helpful tool we’ve developed at Ometis to capture the reload time of the different sections of an app. It takes three lines of code – copy and paste most of it – to define a section, then the time is captured in a separate table in the script that you can use to display in the front-end – or just check from the data model viewer.

The idea is to keep it as simple as possible so everyone can customise it and take advantage of this tool. I like just having it in the app, no changes. Sometimes I’ll create a sheet at the end of the app with the stats in it, some customers like the visibility of this. Other times, I’ll just check the times using the data model viewer or throw a quick chart in a corner of a sheet that I’ll delete once I’m done. Flexibility is king.

A colleague that helped a lot in building this tool, Alex Walker – you’ve probably seen some blog posts from him as well – created an upgraded version of this tool that has layers of code sections and it stores the results to a per-app timestamped QVD. He has an app that loads all those QVDs and has a dashboard to analyse changes between versions, how apps scaled over time, etc. This is just an example of what can be achieved by modifying the Reload Stats to fit your needs.

But, why?

Why create this when you can get an idea of how long things take from the reload log? Simply because this makes it fewer steps to capture and it’s contained within the same app you’re analysing. If you prefer checking the logs and want that separation between the app and the logs, this is not the tool for you and that’s completely fine. But, if you’d rather have it all in one place to be able to quickly compare and check at a glance, please continue reading.

How can you get it?

The base version of the Reload Stats can be found in our GitHub: Reload Stats

To use it, copy the contents of “subReloadStats.qvs” and you will want to paste this early on in your app script. Ideally, I would put this in a section just below the first one that Qlik creates with every new app – Main – that contains the app variables.

Do you like the dark theme? Check my blog post on the subject and join the dark side!

 

Once this is in your app, here’s a quick list of steps to set it up and get some results from it:

 

  • Create a variable that will hold the name of your code section. We use a variable for this so there’s no mistyping when closing a section.

LET log_StageName = ‘Transactions’;

  • Start the timer!

CALL StartLog(log_StageName);

  • Put some code in here, this is what will be timed by the Reload Stats.
  • Stop the timer for your section, here’s where we’ll use the variable again.

CALL StopLog(log_StageName);

  • Repeat this process for each section of code you want to time
  • At the very end of the app, after you’re done with the sections, call the cleanup script and, if you want, deallocate the variable you’ve used for the section names.

CALL CleanupLog;

// Deallocate variables related to Reload Stats

LET log_StageName = null();

I strongly recommend that you check the README.md file in the GitHub repository for optional features and more details about how to use the tool. If you want to access Alex’s more advanced version, it’s available under the “hierarchy” branch.

The future of Reload Stats is in your hands!

Of course, you can just use it as is, but if you want to get involved with the future of this tool, fork the project – make some changes you think will improve it and send us a pull request!

Have you used Reload Stats on your apps and have ideas about how to make it better? Leave us a comment here, submit an issue on GitHub, or send us a Tweet with your thoughts!

I’m very excited to hear your thoughts on this, this is a very handy tool that I use all the time in my projects and I hope it serves you well too. Thanks for reading!

 

By Álvaro Martinez