# perfcounter

> Performance counter with nesting

Latest version **2.1.1** (published 2013-10-10) · MIT license · 0 weekly downloads

## Install

```sh
npm install perfcounter
pnpm add perfcounter
yarn add perfcounter
bun add perfcounter
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.1.1 |
| Published | 2013-10-10 |
| First published | 2013-05-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >= 0.6.0 |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | Dmitry Bashkatov |
| Maintainers | nailgun |
| Keywords | benchmark, performance, speed, timestamp |

## Links

- npm: https://www.npmjs.com/package/perfcounter
- Repository: https://github.com/nailgun/node-perfcounter
- Issues: https://github.com/nailgun/node-perfcounter/issues
- npm.io page: https://npm.io/package/perfcounter

## Dependencies (1)

- [lodash](https://npm.io/package/lodash.md)

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 2.1.1 (latest) — 2013-10-10
- 2.1.0 — 2013-10-10
- 1.0.1 — 2013-09-24
- 1.0.0 — 2013-05-21

## README

PerfCounter
===========

[![Build Status](https://travis-ci.org/nailgun/node-perfcounter.png?branch=master)](https://travis-ci.org/nailgun/node-perfcounter)

Library to collect timing data for your node.js application. Simplifies bottlenecks search.

Usage
-----

``` javascript
var PerfCounter = require('perfcounter'),
    profile = new PerfCounter;

profile.start('Total');
function doSomeJob (callback) {
  profile.start('doSomeJob');

  profile.start('Timeout 1');
  setTimeout(function () {
    profile.stop('Timeout 1');

    profile.start('Timeout 2');
    setTimeout(function () {
      profile.stop('Timeout 2');

      profile.start('Timeout 3');
      setTimeout(function () {
        profile.stop('Timeout 3');

        profile.stop('doSomeJob');
        callback && callback();
      }, 300);
    }, 200);
  }, 100);
}

doSomeJob(function () {
  profile.stop('Total');
  console.log(require('util').inspect(profile.data, false, 10, true));
});
```

Example above will show you something like this:

``` javascript
{ job: 'Total',
  meta: undefined,
  start: 1381415978874,
  children: 
   [ { job: 'doSomeJob',
       meta: undefined,
       start: 1381415978874,
       children: 
        [ { job: 'Timeout 1',
            meta: undefined,
            start: 1381415978874,
            children: [],
            parent: [Circular],
            end: 1381415978978,
            total: 103.757099 },
          { job: 'Timeout 2',
            meta: undefined,
            start: 1381415978978,
            children: [],
            parent: [Circular],
            end: 1381415979178,
            total: 200.49963 },
          { job: 'Timeout 3',
            meta: undefined,
            start: 1381415979178,
            children: [],
            parent: [Circular],
            end: 1381415979480,
            total: 301.456445 } ],
       parent: [Circular],
       end: 1381415979480,
       total: 605.928503,
       missed: 0.215328999999997 } ],
  end: 1381415979480,
  total: 606.061363,
  missed: 0.1328600000000506 }
```

---
_Source: https://npm.io/package/perfcounter · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
