# profiles

> Minimal profiling library.

Latest version **0.2.0** (published 2012-11-21) · MIT license · 0 weekly downloads

## Install

```sh
npm install profiles
pnpm add profiles
yarn add profiles
bun add profiles
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.0 |
| Published | 2012-11-21 |
| First published | 2012-07-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Saam Barati |
| Maintainers | saamyjoon |
| Keywords | profiler, profile, profiling |

## Links

- npm: https://www.npmjs.com/package/profiles
- Repository: https://github.com/saambarati/profiles
- npm.io page: https://npm.io/package/profiles

## Recent versions

- 0.2.0 (latest) — 2012-11-21
- 0.1.1 — 2012-09-25
- 0.1.0 — 2012-08-12
- 0.0.9 — 2012-08-02
- 0.0.8 — 2012-07-30
- 0.0.7 — 2012-07-30
- 0.0.6 — 2012-07-29
- 0.0.5 — 2012-07-29
- 0.0.4 — 2012-07-29
- 0.0.3 — 2012-07-29
- 0.0.2 — 2012-07-29
- 0.0.1 — 2012-07-29

## README

Profiles
========


Profiles is a simple way to profile different parts of your app.

#### Install

    npm install profiles


## API
### Note, These API's *will* change

### Timing

    var profiles = require('profiles')()
    var end = profiles.beg('test1')
    //do something that will take some time
    end() //returns the time from beg to the time end was invoked


### Stats
You can also create stats about certain parts of your app using the `profiler.stat(name, value)` API. If you want to stat how
many request per second your server is handling, you can do the following (this ties in nicely with `ProfilesStream`):

    var reqPerSec = 0
    function serve(req, res) {
      reqPerSec +=1
      res.setHeader('content-type', 'text/plain')
      res.end('request per sec #' + reqPerSec)
    }
    http.createServer(serve).listen(1337)
    setInterval(function() {
      profiler.stat('perSec', reqPerSec)
      reqPerSec = 0
    }, 1000)
    profiles.PS(profiler).pipe(process.stdout)


### Events
Profiles is also an instance of EventEmitter so you can listen to the `profile` event which takes a listener function:

     profiles.on('profile', function(profileName, value, profileType, uid) {})
     /*
      * profileName will be the name of the stat or time
      * value is the 'time' it took  before the end() function was invoked or the 'stat' value when you call stat()
      * profileType will be the type of profile you invoked, so: 'stat' or 'time'
      * uid is a unique ID, currently this is just Date.now()
     */

### ProfilesStream
You can also wrap your profiler in a `readable stream`:

    var profiles = require('profiles')
      , profiler = profiles()
      , pStream = new profiles.PS(profiler)
      // OR:  pStream = new profiles.ProfilesStream(profiler)

    pStream.pipe(process.stdout)

`ProfilesStream` just listens in on the `"profile"` event and emits `\n` delimited JSON string `Buffer` objects that have the following format:

    {'name' : nameOfStatOrTime, 'val': itsValue, '__profileType' : 'time' OR 'stat', __uid : ID }


##### MIT License

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