8

React Native benchmarking library inspired by benchmark.js

 3 years ago
source link: https://reactnativeexample.com/react-native-benchmarking-library-inspired-by-benchmark-js/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Benchmark

React Native benchmarking library inspired by benchmark.js

Apr 18, 2021 1 min read

react-native-benchmark

React Native benchmarking library inspired by benchmark.js and written in TypeScript.

Installation

npm i -s benchmark-ts
Shell

Usage

// example/index.ts
import { EventType, Suite } from "../src";

const suite = new Suite;

suite.add('RegExp#test', () => {
  /o/.test('Hello World!');
})
.add('String#indexOf', () => {
  'Hello World!'.indexOf('o') > -1;
})
.add('String#match', () => {
  !!'Hello World!'.match(/o/);
})
.on(EventType.CYCLE, (event) => {
  // console.log(event.type, event.target.times);
})
.on(EventType.COMPLETE, (event) => {
  // const s:Suite = event.target as Suite
  console.log(suite.toString())
})
.run({async: true});
TypeScript

GitHub

https://github.com/eugenehp/react-native-benchmark

Previous Post

A simple React Native date input component

Subscribe to React Native Example for Android and iOS

Get the latest posts delivered right to your inbox


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK