Measure and show FPS and (on iOS) CPU usage!
20 sec video, showing off the plugin on iOS and Android
From the command prompt go to your app's root folder and execute:
tns plugin add nativescript-performance-monitor
After adding the plugin you can start monitoring from code. There are a few options you can pass in as well (the options object itself is optional as well):
Option | iOS? | Android? | Description |
---|---|---|---|
onSample? |
|
|
A callback function that gets invoked on every sample. If you don't want to use the default UI of this plugin you can use this to render your own UI. See the examples below for the function spec. |
hide? |
|
|
Set to true if you don't want the default UI to show. So roll your own or go ito stealth mode entirely. |
textColor? |
|
|
The text color of the monitor view (default white). |
backgroundColor? |
|
|
Background color of the monitor view (default black). |
borderColor? |
|
|
The border color of the monitor view (default black). |
import { PerformanceMonitor, PerformanceMonitorSample } from 'nativescript-performance-monitor';
import { Color } from "color";
const performanceMonitor: PerformanceMonitor = new PerformanceMonitor();
// this would suffice..
performanceMonitor.start();
// .. but we want to show off the options ;)
performanceMonitor.start({
textColor: new Color("white"),
backgroundColor: new Color("black"),
borderColor: new Color("black"),
hide: false,
onSample: (sample: PerformanceMonitorSample) => {
console.log("FPS: " + sample.fps);
if (sample.cpu) { // iOS only
console.log("CPU %: " + sample.cpu);
}
}
});
var perfMon = require("nativescript-performance-monitor");
var color = require("color");
var performanceMonitor = new perfMon.PerformanceMonitor();
performanceMonitor.start({
textColor: new color.Color("white"),
backgroundColor: new color.Color("black"),
borderColor: new color.Color("black"),
hide: false,
onSample: function (sample) {
console.log("FPS: " + sample.fps);
if (sample.cpu) { // iOS only
console.log("CPU %: " + sample.cpu);
}
}
});
To stop receiving measurements and hide the monitor UI you can simply do this:
performanceMonitor.stop();
In any component, or even app.module.ts
add:
import { PerformanceMonitor } from "nativescript-performance-monitor";
export class MyComponent {
// use the constructor, or OnInit, or trigger from a button, or whatever really
constructor() {
new PerformanceMonitor().start({
// options
});
}
}
测试环境 类型 配置 MySQL A Intel(R) Xeon(R) CPU E5-2430 0 @ 2.20GHz (24core 96G) MySQL B Intel(R) Xeon(R) CPU E5-2430 0 @ 2.20GHz (24core 96G) 日常业务库 Canal Server Intel(R) Xeon(R) CPU E5-2430 0 @ 2.20GHz (24co
HTTP Request Performance Comparision This section will compare the performance of different Ingress controller(F5, Nginx, HAProxy) to process simple http request. Software Used wrk 4.1.0 k8s 1.15.12,
Handsontable performs multiple calculations to display the grid properly. The most demanding actions are performed on load, change and scroll events. Every single operation decreases the performance,
This guide contains a collection of best practices for optimizing your TensorFlow code. The best practices apply to both new and experienced Tensorflow users. Best Practices While optimizing implement
Performance is often a significant issue when training a machine learning model. This section explains various ways to optimize performance. Start your investigation with the following guide: @{$perfo
When it comes to mobile apps, performance is critical to user experience. Users expect apps to have smooth scrolling and meaningful animations free of stuttering or skipped frames, known as “jank.” Ho