Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/MaxGraey/react-native-console-time-polyfill
console.time and console.timeEnd polyfill for react-native
https://github.com/MaxGraey/react-native-console-time-polyfill
console measurements performance polyfill react-native time
Last synced: 2 months ago
JSON representation
console.time and console.timeEnd polyfill for react-native
- Host: GitHub
- URL: https://github.com/MaxGraey/react-native-console-time-polyfill
- Owner: MaxGraey
- License: mit
- Created: 2017-03-06T17:45:24.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2021-04-03T10:00:14.000Z (about 3 years ago)
- Last Synced: 2024-01-25T12:10:54.495Z (5 months ago)
- Topics: console, measurements, performance, polyfill, react-native, time
- Language: JavaScript
- Size: 12.7 KB
- Stars: 102
- Watchers: 4
- Forks: 7
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Lists
- awesome-react-native - react-native-console-time-polyfill ★45 - console.time and console.timeEnd polyfill for react-native (Components / Utils & Infra)
- awesome - react-native-console-time-polyfill ★45 - console.time and console.timeEnd polyfill for react-native (Components / Utils & Infra)
- awesome-react-native - react-native-console-time-polyfill ★45 - console.time and console.timeEnd polyfill for react-native (Components / Utils & Infra)
- awesome-react-native - react-native-console-time-polyfill ★16 - console.time and console.timeEnd polyfill for react-native (Components / Utils & Infra)
- awesome-react-native - react-native-console-time-polyfill ★45 - console.time and console.timeEnd polyfill for react-native (Components / Utils & Infra)
- awesome-react-native-ui - react-native-console-time-polyfill ★2 - console.time and console.timeEnd polyfill for react-native (Components / Utils & Infra)
- awesome-react-native - react-native-console-time-polyfill ★45 - console.time and console.timeEnd polyfill for react-native (Components / Utils & Infra)
- awesome-react-native - react-native-console-time-polyfill ★45 - console.time and console.timeEnd polyfill for react-native (Components / Utils & Infra)
- awesome-react-native - react-native-console-time-polyfill ★16 - console.time and console.timeEnd polyfill for react-native (Components / Utils & Infra)
README
## react-native-console-time-polyfill
Starts a timer you can use to track how long an operation takes. When you call ***console.timeEnd()/console.timeLog()*** with the same name, the react-native will output the time, in milliseconds, that elapsed since the timer was started.
Also you can use ***console.count()*** and ***console.countReset()*** for determine number of function calls.
### Installation
Install library from **npm**
```bash
npm install --save react-native-console-time-polyfill
```or **yarn**
```bash
yarn add react-native-console-time-polyfill
```### Syntax
```javascript
console.time(label);
console.timeLog(label);
console.timeEnd(label);console.count(label);
console.countReset(label);
```### Parameters
***label***
The name to give the new timer or counter. This will identify the timer or counter.
Use the same name when calling ***console.timeEnd()*** to stop the timer and get the time output to the console.
### Usage
Use the following code:
```javascript
// in your root javascript file
import 'react-native-console-time-polyfill';// now you can use polyfill in your components
class Example extends Component {
constructor(props) {
super(props);console.time(`${this.constructor.name} init`);
// "some slow initializaton code"
console.timeEnd(`${this.constructor.name} init`);
}componentWillUnmount() {
console.countReset(`${this.constructor.name}.render calls`);
}render() {
console.count(`${this.constructor.name}.render calls`);
return (
some text;
);
}
}
```### Output
```
Example init: 200ms
Example.render calls: 2
```