# v8-perf-shield

> V8应用性能守护者，当应用运行状态超过设定的警戒线后会触发救援函数，救援函数主要用于应急处理，比如自动重启进程，在救援函数中也可以获取到性能数据的历史以便输出到日志中。

Latest version **1.0.4** (published 2016-04-19) · ISC license · 0 weekly downloads

## Install

```sh
npm install v8-perf-shield
pnpm add v8-perf-shield
yarn add v8-perf-shield
bun add v8-perf-shield
```

## 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.0.4 |
| Published | 2016-04-19 |
| First published | 2016-03-19 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 5 |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Guokai |
| Maintainers | paulguo |

## Links

- npm: https://www.npmjs.com/package/v8-perf-shield
- Repository: https://github.com/PaulGuo/v8-perf-shield
- Homepage: https://github.com/PaulGuo/v8-perf-shield#readme
- Issues: https://github.com/PaulGuo/v8-perf-shield/issues
- npm.io page: https://npm.io/package/v8-perf-shield

## Dependencies (5)

- [usage](https://npm.io/package/usage.md) ^0.7.1
- [log4js](https://npm.io/package/log4js.md) ^0.6.33
- [writefile](https://npm.io/package/writefile.md) ^0.2.8
- [v8-profiler](https://npm.io/package/v8-profiler.md) ^5.6.0
- [object-assign](https://npm.io/package/object-assign.md) ^4.0.1

## Recent versions

- 1.0.4 (latest) — 2016-04-19
- 1.0.3 — 2016-03-19
- 1.0.2 — 2016-03-19
- 1.0.1 — 2016-03-19
- 1.0.0 — 2016-03-19

## README

## V8-Perf-Shield

V8应用性能守护者，当应用运行状态超过设定的警戒线后会触发救援函数，救援函数主要用于应急处理，比如自动重启进程，在救援函数中也可以获取到性能数据的历史以便输出到日志中。

### 如何安装

```
npm install --save v8-perf-shield
```

### 使用方法

```
'use strict';

var perfShield = require('v8-perf-shield');

perfShield({
    logsPath: '', // 分析文件保存路径，默认为当前路径
    samplingTime: 60, // 采样时间，用于CPU Profile的生成
    flushTime: 3, // 检查时间，用于定期检查系统用量
    cacheMaxLimit: 100, // 最大历史缓存条数，超过则滚动
    usageOptions: { keepHistory: true },

    emergencyCondition: function (lastUsage, currentUsage, usageHistory) {
        if (lastUsage.cpu > 5 && currentUsage.cpu > 5) {
            return true;
        }
    },

    emergencyAction: function (usageHistory) {
        console.log(usageHistory);
        process.exit(0);
    }
});
```

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