https://github.com/jcoreio/profiler-server
https://github.com/jcoreio/profiler-server
Last synced: about 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/jcoreio/profiler-server
- Owner: jcoreio
- License: mit
- Created: 2019-12-10T19:27:42.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2023-01-24T00:55:26.000Z (over 3 years ago)
- Last Synced: 2025-02-01T01:41:38.706Z (over 1 year ago)
- Language: TypeScript
- Homepage:
- Size: 1 MB
- Stars: 0
- Watchers: 4
- Forks: 0
- Open Issues: 27
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# @jcoreio/profiler-server
[](https://circleci.com/gh/jcoreio/profiler-server)
[](https://codecov.io/gh/jcoreio/profiler-server)
[](https://github.com/semantic-release/semantic-release)
[](http://commitizen.github.io/cz-cli/)
[](https://badge.fury.io/js/%40jcoreio%2Fprofiler-server)
REST server for running v8-profiler and downloading snapshots
# API
## `ProfilerRouter({ profiler: Profiler, maxDurationMillis?: number | null })`
```js
import { ProfilerRouter } from '@jcoreio/profiler-server'
```
Creates an [ExpressJS Router](https://devdocs.io/express/index#express.router) that handles
the following routes:
### Options
- `profiler: Profiler` (**required**) - the profiler to use, for example `require('v8-profiler-next')`
- `maxDurationMillis: number` (_optional_, default: 5 minutes) - the maximum cpu profile duration to allow
### Example
```js
import { ProfilerRouter } from '@jcoreio/profiler-server'
import profiler from 'v8-profiler-next'
import express from 'express'
const app = express()
app.use(ProfilerRouter({ profiler }))
```
### `GET /cpu?durationMillis=`
Profiles the CPU for `durationMillis` milliseconds, and sends the CPU profile in the response.
**You must set the timeout of the client request to more than `durationMillis`** or the request
will time out.
If a CPU profile is already in progress, responds with 418.
### `GET /heap`
Takes a heap snapshot and sends it in the response.
### `GET /sampleHeapProfiling?durationMillis=`
Profiles heap sampling for `durationMillis` milliseconds, and sends the profile in the response.
**You must set the timeout of the client request to more than `durationMillis`** or the request
will time out.
If a heap sampling profile is already in progress, responds with 418.
#### Query parameters
- `durationMillis` (**required**) the amount of time to profile in milliseconds
- `interval` (**optional**) the sampling interval, in milliseconds (has no effect unless `depth` is also given)
- `depth` (**optional**) the sampling depth (has no effect unless `interval` is also given)
### `GET /gc`
Runs the garbage collector.