1.2.3 • Published 7 years ago

miniprofiler v1.2.3

Weekly downloads
5
License
Apache-2.0
Repository
github
Last release
7 years ago

MiniProfiler for Node.js

Node.js implementation of Stack Exchange's MiniProfiler

NPM Build Coverage Dependencies devDependencies

Demonstration

Visit http://miniprofiler-demo.herokuapp.com for a live demonstration.

Installation

$ npm install miniprofiler

You can hook up your application with any of the following packages are available on npm:

NameAboutVersion
miniprofiler-httpProfile http(s) requestsNPM
miniprofiler-pgProfile pg queriesNPM
miniprofiler-redisProfile redis callsNPM

Usage

Simple usage with express.js

server.js

var express = require('express')
  , miniprofiler = require('miniprofiler')
  , app = express();

app.set('view engine', 'pug');
app.use(miniprofiler.express());

app.get('/', function(req, res) {
  req.miniprofiler.step('Step 1', function() {
    req.miniprofiler.step('Step 2', function() {
      res.render('index');
    });
  });
});

app.listen(8080);

index.pug

doctype html
html
  head
    title MiniProfiler Node.js Example
  body
    h1 Home Page
    | !{miniprofiler.include()}

When visiting localhost:8080, you should see this.

npm.io

API

miniprofiler.{framework}([options])

Replace {framework} with koa, express or hapi.

This function returns a framework specific middleware that is responsible for initializing MiniProfiler on each request.

options object properties

PropertyDefaultDescription
enableAlways returns truefunction(req, res) => boolean; this function is used to determine if the profiler should be enabled for the current request
authorizeAlways returns truefunction(req, res) => boolean; this function is used to determine if the current request should be able to see the profiling results

miniprofiler.{framework}.for([provider])

provider is a call for any of the supported providers listed here.

miniprofiler.configure([options])

options object properties

PropertyDefaultDescription
storageInMemoryStorage({ max: 100, maxAge: 1000 * 60 * 60 })InMemoryStorage or RedisStorage; used to store or fetch a string JSON blob of profiling information
ignoredPaths string array ; any request whose url property is in ignoredPaths will not be profiled
trivialDurationThresholdMilliseconds2.5double ; any step lasting longer than this will be considered trivial, and hidden by default
popupShowTimeWithChildrenfalseboolean ; whether or not to include the "time with children" column
popupRenderPositionleft'left', 'right', 'bottomLeft' or 'bottomRight' ; which side of the screen to display timings on

options.storage examples

InMemoryStorage

miniprofiler.configure({
  storage: miniprofiler.storage.InMemoryStorage({ lruCacheOptions });
})

Refer to lru-cache documentation for lruCacheOptions.

RedisStorage

miniprofiler.configure({
  storage: miniprofiler.storage.RedisStorage(client);
})

Where client is an instance of redis.createClient.

1.2.3

7 years ago

1.2.2

7 years ago

1.2.1

8 years ago

1.2.0

8 years ago

1.1.3

8 years ago

1.1.2

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago

0.2.7

8 years ago

0.2.6

8 years ago

0.2.5

8 years ago

0.2.3

8 years ago

0.2.2

8 years ago

0.2.1

8 years ago

0.2.0

8 years ago

0.1.0

8 years ago

0.0.9

8 years ago

0.0.8

11 years ago

0.0.7

11 years ago

0.0.6

11 years ago

0.0.5

11 years ago

0.0.4

11 years ago

0.0.3

11 years ago

0.0.2

11 years ago

0.0.1

11 years ago