npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

tinyprofiler

v0.0.5

Published

A minimal isomorphic JavaScript profiler.

Downloads

11

Readme

tinyprofiler

a minimal isomorphic JavaScript profiler strongly influenced by MiniProfiler

introduction

tinyprofiler is a minimal isomorphic JavaScript profiler, inspired by MiniProfiler but adapted to the asynchronous nature of JavaScript.

getting started

If you have node.js and npm set up, install with:

> npm install --save tinyprofiler

Mount tp.middleware.resource and tp.middleware.profiling as the first middlewares on your stack. If you'd also like to view the results in the browser, take a look at tinyprofiler-client. See the example folder for more information.

faq

Isn't MiniProfiler great? Why wouldn't I just use that?

There are two main reasons you might use tinyprofiler over MiniProfiler. tinyprofiler is designed first and foremost to be isomorphic, so the same profiler can be used on the client and server. This is great for many JavaScript projects, but critical for ones aiming for the Holy Grail of an isomorphic codebase.

More broadly, the data model for MiniProfiler doesn't really adapt to the async-by-default nature of born-on-the-web JavaScript. tinyprofiler offers explicit synchronous and asynchronous APIs.

documentation

  • data structure
  • options
  • api methods
  • express middleware

data structure

{
  "id": "jZKO20skdk0983sF",
  "name": "GET /users/1234",
  "start": "1972-06-15T12:38:43Z",
  "length": [0, 270261496],
  "steps": [
    {
      "name": "query Users",
      "start": [0, 49920582],
      "length": [0, 101885726]
    },
    {
      "name": "send results",
      "start": [0, 163945603],
      "length": [0, 256993038],
      "steps": [
        {
          "name": "format user",
          "start": [0, 28373405],
          "length": [0, 77504993]
        }
      ]
    }
  ]
}

the recursive data structure has the following properties:

  • id: a guid for the request [root only]
  • name: the name of the step
  • details: additional information [optional]
  • start: the start time of the step [iso date on root]
  • length: the finish time of the step
  • steps: any child steps [optional]

all timings are relative to the start time of their parent, and are recorded in the format of process.hrtime(). each timing is a pair of integers - the first the number of seconds since the start of the parent, and the second the number of nanoseconds.

the start entry for the root has an iso date string representing the start time of the entire profile.

options

tinyprofiler accepts a variety of configuration options. Many of these are shared between client and server code, but some of them are only applicable to one or the other.

n.b. the following also documents options for tinyprofiler-client.

shared options

These opitons should be identical between the client and the server.

headerName - "X-TinyProfiler-Ids"

the name of the HTTP header to use to send profile ids

path - "tp"

server path to mount tinyprofiler REST API

profilerKey - "profiler"

key name on request object to store request-scoped profiler

distinct options

These options have the same meaning on the client and server, but nevertheless are frequently different in the two environments.

requestName - (req) -> "#{req.method} #{req.path}"

function to build profile name from request object (method defaults to "AJAX" on client)

requestDetails - (req) ->

function to build profile details from request object

server options

profileResponse - true

do we automatically profile the server response?

client options

maxProfiles - 20

the maximum number of old profiles to hold on to.

monkeyPatch - true

do we automatically monkey patch the XHR object?

profileRequest - true

do we automatically profile each XHR request?

api methods

soon

events

TinyProfiler extends EventEmitter2 to provide status updates to any listeners you may have. TinyProfiler emits two events: update and complete. update is emitted any time there is new step timing information, and complete is emitted after each completed request. Both are supplied with the relevant request profiler object.

express middleware

forthcoming

license

MIT: https://couch.mit-license.org/

╭╮☲☲☲╭╮