Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/iagocalazans/pmeter
SpingAge is a simple function performance meter.
https://github.com/iagocalazans/pmeter
Last synced: 3 days ago
JSON representation
SpingAge is a simple function performance meter.
- Host: GitHub
- URL: https://github.com/iagocalazans/pmeter
- Owner: iagocalazans
- License: mit
- Created: 2021-01-16T14:23:24.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2021-01-16T21:08:51.000Z (almost 4 years ago)
- Last Synced: 2024-11-08T08:45:44.133Z (about 2 months ago)
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/spingage
- Size: 31.3 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# SpingAge - Performance Meter
SpingAge is a simple function performance meter.## How to use
### This is a sample express server running pmeter at some of it functions.
If you use "import"
```
import { spingMark } from 'spingage';
```
If you use "require"
```
const express = require('express');
const app = express();const spingMark = require('spingage').spingMark;
app.get('/', (req, res) => {
spingMark(myLoopOneParam, 5000);spingMark(myLoopMultipleParams, 3000, 5000);
res.status(201).send({ some: { crazy: 'Object' }})
})const myLoopOneParam = (ms) => {
let i = 0;
while(i < ms) {
console.log(i);
i++
}
return i;
}const myLoopMultipleParams = (params) => {
let [i, ms] = params;while(i < ms) {
console.log(i);
i++
}
return i;
}app.listen(3000, () => {
console.log('Listening p;ort 3000')
})
```### You can pass many parameters as you wish
Just input your parameters separateds by comma and deconstruct them on the function.```
spingMark(function, ...params);
```### You can measure more complex functions too
For more complex functions, call them as anonymous functions retuns.```
spingMark(() => function(...params));
```### This is how it will be printed
You will receive 2 blocks of info, SERVER USAGE and PERFORMANCE.```
FUNCTION myLoopOneParamSERVER USAGE
[CPU] 19%
[RAM] 0 MB
[RSS] 5.07 MB
[EXT] 0 MB
[BUFFER] 0 MBPERFORMANCE
[EXEC TIME] 2080ms
CLOSE
FUNCTION myLoopMultipleParams
SERVER USAGE
[CPU] 21%
[RAM] 1.96 MB
[RSS] 0 MB
[EXT] 0 MB
[BUFFER] 0 MBPERFORMANCE
[EXEC TIME] 664ms
CLOSE
```