当前位置: 首页 > 软件库 > 手机/移动开发 > >

nativescript-performance-monitor

授权协议 View license
开发语言 JavaScript TypeScript
所属分类 手机/移动开发
软件类型 开源软件
地区 不详
投 递 者 广晔
操作系统 iOS
开源组织
适用人群 未知
 软件概览

NativeScript Performance Monitor

Measure and show FPS and (on iOS) CPU usage!

Demo video on YouTube

20 sec video, showing off the plugin on iOS and Android

Installation

From the command prompt go to your app's root folder and execute:

tns plugin add nativescript-performance-monitor

Start monitoring

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).

TypeScript

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);
    }
  }
});

JavaScript

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);
    }
  }
});

Stop monitoring

To stop receiving measurements and hide the monitor UI you can simply do this:

performanceMonitor.stop();

Usage with Angular

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
    });
  }
}

Known issues (Android)

  • May crash when a Toast is shown on newer Android versions while you're using the default UI.
  • UI will hide when app is pauzed / resumed.
 相关资料
  • 测试环境 类型 配置 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