Skip to content

WeChat Mini Program wx.reportPerformance Library

Github link:

Tencent’s WeChat Mini Program has a very robust native performance report tool. But I can’t find any library/util functions that utilize this tool. So, I decided to make one for my own usage, and as well make a tutorial on how to implement it in your projects. You can start by download the code from my repository here. The code should run out of the box in the WeChat Devtool. Make sure you’re using the latest version of WeChat devtool.

This simple project is a demo, I use API to simulate API call performance.

About wx.reportPerformance

wx.reportPerformance function can send performance data from client’s device, which means the data provided will reflecting your actual mini program performance from your users/audiences point of view. Tencent also provides a user friendly back office interface to view the data. You can access this back office from your WeChat mini program back office admin page.

To begin using wx.reportPerformance, you need to enable this feature in the back office admin page via 开发管理运维中心小程序测速. After you enabled this feature, you can start to create parameters that you want to measure. There are two types of performance that you can measure, 1) network performance or 2) device performance. Each parameter will have a four digit number as an ID. Network performance ID will start with ‘1‘, while device performance ID will start with ‘2‘. Here are my network performance settings that I use.

  • ‘RENDER’: 2002
  • ‘SCRIPT’: 2003,

After you configured it in the Mini Program back office, you can set the parameters in the performanceConfig.js file. The config file has cleanUrl and debug configuration. I will explain about it more later. Here is my performanceConfig.js file example:


After you configure the performance config, do some configurations in the app.js to enable the performance monitoring. I did this by calling the enablePerformanceMonitoring function in the app.onShow method, and disablePerformanceMonitoring function in the app.onHide method. Make sure to pass this argument when calling the function.

app.js config

One last configuration that you need to do, is to measure your API calls, I did this by using some local variables in my global request function. The variables store time before and after API call. Then, pass the duration into the reportApiPerformance function.

compute API duration in your request function, then pass the value into reportApiPerformance function

Note that you need to pass the correct code for API performance. Here I use environment from the config file, you need to modify this accordingly. If you have configured your mini program appId, and you have access to your own mini program back office, you can navigate to, and see your data. It should looked like this:

image taken from Tencent’s documentation

The report itself is quite complete, you can see the user’s client information, such as iOS/Android phone, or high/mid/low-end phone. While for API performance, you can view the geographical data based on user’s province. Which really depends on your API server location, server performance, and user’s internet connection speed. Personally I noticed that west part of China (such as Xinjiang or Tibet) has the slowest API performance compared with other regions. The data I got is pretty much similar to this article about China’s internet connection speed. Shanghai’s internet speed is ranked #1 in the article 🙂

Published inTech


  1. %%

    Feel free to visit my web-site northville 18 wheeler accident (Lynn)

  2. %%

    Also visit my web blog :: berkeley railroad injuries, Desiree,

  3. Comprare patente di guida reale e registrata sul nostro sito web senza sostenere alcun esame o fare la prova pratica. tutto ciò di cui abbiamo bisogno sono i tuoi dati e verranno registrati nel sistema entro i prossimi otto giorni. Le patenti di guida devono seguire la stessa procedura di registrazione di quelle rilasciate nelle autoscuole

  4. lkw führerschein kaufen ohne prüfung österreich, motorrad  führerschein kaufen , bus führerschein kosten österreich. führerschein online kaufen, auto c ohne prüfung köln, führerschein klasse b kaufen, deutschen registrierten führerschein kaufen berlin, österreich führerschein kaufen legal in deutschland, führerschein in deutschland kaufen, PKW führerschein kaufen österreich, deutschen führerschein legal kaufen in österreich, kaufe deutschen führerschein, eu-führerschein kaufen,wie viel kostet der führerschein in österreich.

Leave a Reply

Your email address will not be published. Required fields are marked *