https://github.com/tyrealgray/analysis.js
A simply javascript library for using performance api in both Node.js and web easier
https://github.com/tyrealgray/analysis.js
node-module nodejs perf-hooks performance web
Last synced: 25 days ago
JSON representation
A simply javascript library for using performance api in both Node.js and web easier
- Host: GitHub
- URL: https://github.com/tyrealgray/analysis.js
- Owner: TyrealGray
- License: mit
- Created: 2020-04-10T12:15:32.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2023-01-06T03:06:20.000Z (over 3 years ago)
- Last Synced: 2025-01-10T22:23:46.506Z (over 1 year ago)
- Topics: node-module, nodejs, perf-hooks, performance, web
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/analysis.js
- Size: 283 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Analysis.js
A simply javascript library for using performance api in both Node.js and web easier
## Install
`$ npm i analysis.js --save`
## Usage
```javascript
import { Analysis } from 'analysis.js';
...
const performance = Analysis.getPerformance();
performance.now();
const performanceObserver = Analysis.getPerformanceObserver();
const perf_observer = (list, observer) => {
// Process the "measure" event
};
const observer2 = new performanceObserver(perf_observer);
observer2.observe({entryTypes: ["measure"]});
```
**`Analysis.getPerformance()`** in web context will return `window.performance`, and in Node.js context will return `perf_hooks.performance`.
So `performance.getEntries()` will not work in Node.js context, you will need to use `PerformanceObserver` to get the list.