react-native-console-time-polyfill
console.time, console.timeLog and console.timeEnd polyfill for react-native
Last updated 4 years ago by maxgraey .
MIT · Repository · Original npm · Tarball · package.json
$ npm install react-native-console-time-polyfill 
SYNC missed versions from official npm registry.

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

npm install --save react-native-console-time-polyfill

or yarn

yarn add react-native-console-time-polyfill

Syntax

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:

// 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 (
      <Text>some text</Text>;
    );
  }
}

Output

Example init: 200ms
Example.render calls: 2

Current Tags

  • 1.2.3                                ...           latest (4 years ago)

12 Versions

  • 1.2.3                                ...           4 years ago
  • 1.2.2                                ...           4 years ago
  • 1.2.1                                ...           6 years ago
  • 1.2.0                                ...           6 years ago
  • 1.1.0                                ...           6 years ago
  • 1.0.0                                ...           6 years ago
  • 0.0.6                                ...           8 years ago
  • 0.0.5                                ...           8 years ago
  • 0.0.4                                ...           8 years ago
  • 0.0.3                                ...           8 years ago
  • 0.0.2                                ...           8 years ago
  • 0.0.1                                ...           8 years ago
Maintainers (1)
Downloads
Total 0
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (0)
None
Dev Dependencies (0)
None

© 2010 - cnpmjs.org x YWFE | Home | YWFE