# plover-benchmark

> 提供性能监控工具，以及记录模块渲染时间

Latest version **1.1.0** (published 2016-10-06) · ISC license · 0 weekly downloads

## Install

```sh
npm install plover-benchmark
pnpm add plover-benchmark
yarn add plover-benchmark
bun add plover-benchmark
```

## 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 | 1.1.0 |
| Published | 2016-10-06 |
| First published | 2016-06-20 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | bencode@163.com |
| Maintainers | bencode |

## Links

- npm: https://www.npmjs.com/package/plover-benchmark
- Repository: https://github.com/ploverjs/plover-benchmark
- Homepage: https://github.com/ploverjs/plover-benchmark#readme
- Issues: https://github.com/ploverjs/plover-benchmark/issues
- npm.io page: https://npm.io/package/plover-benchmark

## Dependencies (2)

- [plover-logger](https://npm.io/package/plover-logger.md) ~1.4.1
- [output-formatter](https://npm.io/package/output-formatter.md) ~1.0.2

## Recent versions

- 1.1.0 (latest) — 2016-10-06
- 1.0.0 — 2016-06-20

## README

# plover-benchmark


[![NPM version][npm-image]][npm-url]
[![build status][travis-image]][travis-url]
[![Test coverage][coveralls-image]][coveralls-url]


提供性能监控工具方法，记录模块渲染时间


## 接入

在应用中引入此插件

```
npm install --save plover-benchmark
```

1\. 默认情况下不会记录性能日志，可以通过以下配置开启 

```js
{
  benchmark: {
    enable: true
  }
}
``` 

2\. 启动时添加环境变量 `DEBUG_BENCHMARK=true` 也可以记录日志


```
$ DEBUG_BENCHMARK=true npm run start
```

## 使用

可以调用`benchmark` service提供的方法来记录调用时间

in middleware

```js
module.exports = function() {
  return function* () {
    ...
    const done = this.benchmark.mark('request-some-data');   // mark start
    yield requestSomeData();
    done();   // mark end
  };
}
```

开启`benchmark`后在控制台会得到类似以下输出:

```
                      plover-benchmark
------------------------------------------------------------
                       name                        cost(ms)
------------------------------------------------------------
request                                                196
cache-service                                           61
index:view.action                                       32
get view data                                            9
index:view.render                                       14
 index:item.action                                      11
unknow request                                      unknow
 index:item.render                                       0
 layouts:view.action                                    84
 layouts:view.render                                     0
```

[npm-image]: https://img.shields.io/npm/v/plover-benchmark.svg?style=flat-square
[npm-url]: https://www.npmjs.com/package/plover-benchmark
[travis-image]: https://img.shields.io/travis/ploverjs/plover-benchmark/master.svg?style=flat-square
[travis-url]: https://travis-ci.org/ploverjs/plover-benchmark
[coveralls-image]: https://img.shields.io/codecov/c/github/ploverjs/plover-benchmark.svg?style=flat-square
[coveralls-url]: https://codecov.io/github/ploverjs/plover-benchmark?branch=master

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