百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
N

node

> 编程语言
开源

一个简单但有效的 Node.js 网站迷你分析器

198 stars0 点赞2 次浏览
访问官网GitHub

工具介绍

一个简单但有效的 Node.js 网站迷你分析器

MiniProfiler for Node.js

Node.js implementation of Stack Exchange's MiniProfiler

Demonstration

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

Installation

bash
$ npm install miniprofiler

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

Name About Version
miniprofiler-http Profile http(s) requests
miniprofiler-pg Profile pg queries
miniprofiler-redis Profile redis calls

Usage

Simple usage with express.js

server.js

javascript
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

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

When visiting localhost:8080, you should see this.

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

Property Default Description
enable Always returns true function(req, res) => boolean; this function is used to determine if the profiler should be enabled for the current request
authorize Always returns true function(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

Property Default Description
storage InMemoryStorage({ 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
trivialDurationThresholdMilliseconds 2.5 double ; any step lasting longer than this will be considered trivial, and hidden by default
popupShowTimeWithChildren false boolean ; whether or not to include the "time with children" column
popupRenderPosition left '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.

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

JavaScript

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言