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 🙏

© 2026 – Pkg Stats / Ryan Hefner

pr-duration-metrics

v1.0.0

Published

Analyze average time spent on pull requests in a GitHub repository.

Readme

PR Duration Metrics

npm version License: MIT

A command-line tool that analyzes GitHub pull request durations, showing how long PRs were open before being merged or closed.

PR Duration Metrics Screenshot

Features

  • Analyze how long PRs stay open in your GitHub repositories
  • View average and median PR resolution times
  • Identify the slowest PRs that may need attention
  • Filter by time period (days to look back)
  • Configurable report of the slowest open PRs
  • Support for both merged and closed (abandoned) PRs
  • Human-readable duration formatting
  • Colorized console output for better readability

Installation

Global Installation (Recommended)

npm install -g pr-duration-metrics-metrics

Local Installation

npm install pr-duration-metrics-metrics

Prerequisites

  • Node.js 14.x or higher
  • A GitHub Personal Access Token with repo scope

Usage

Setting up GitHub Token

Create a GitHub Personal Access Token with repo scope and set it as an environment variable:

export GITHUB_TOKEN=your_github_token

For Windows:

set GITHUB_TOKEN=your_github_token

Basic Usage

npx pr-duration-metrics -o <organization> -r <repository>

Full Usage

pr-duration-metrics -o <organization> -r <repository> -d <days> -t <top> -c

Command Options

| Option | Alias | Description | Default | |--------|-------|-------------|---------| | --org | -o | GitHub organization name (required) | - | | --repo | -r | GitHub repository name (required) | - | | --days | -d | Number of days to look back | 30 | | --top | -t | Number of slowest PRs to display | 10 | | --show-closed | -c | Include closed (not merged) PRs | false | | --help | -h | Show help | - | | --version | -V | Show version number | - |

Examples

Analyze PR durations for the React repository over the last 30 days:

pr-duration-metrics -o facebook -r react

Analyze PR durations for your personal repository over the last 60 days and show the 15 slowest PRs:

pr-duration-metrics -o yourusername -r your-repo -d 60 -t 15

Include closed (not merged) PRs in the analysis:

pr-duration-metrics -o yourusername -r your-repo -c

Example Output

PR Duration Analysis
Analyzing facebook/react for the last 30 days

==================================================================================
        PR DURATION REPORT - LAST 30 DAYS
==================================================================================
┌──────────────────────────────┬──────────────────────────────────────────────────┐
│ Metric                       │ Value                                            │
├──────────────────────────────┼──────────────────────────────────────────────────┤
│ Total PRs                    │ 142                                              │
├──────────────────────────────┼──────────────────────────────────────────────────┤
│ Merged PRs                   │ 95                                               │
├──────────────────────────────┼──────────────────────────────────────────────────┤
│ Closed PRs (not merged)      │ 47                                               │
├──────────────────────────────┼──────────────────────────────────────────────────┤
│ Average Merged PR Duration   │ 3d 5h (77.42 hours)                             │
├──────────────────────────────┼──────────────────────────────────────────────────┤
│ Median Merged PR Duration    │ 1d 14h (38.00 hours)                            │
└──────────────────────────────┴──────────────────────────────────────────────────┘

Top 10 Slowest PRs:
┌───────┬────────────────────────────────────────┬───────────────┬──────────┬───────────────┬──────────────────────────────────┐
│ #     │ Title                                  │ Author        │ Status   │ Duration      │ URL                              │
├───────┼────────────────────────────────────────┼───────────────┼──────────┼───────────────┼──────────────────────────────────┤
│ 24975 │ [React 18] Update useTransition to...  │ acdlite       │ merged   │ 23d 7h        │ https://github.com/facebook/re...│
├───────┼────────────────────────────────────────┼───────────────┼──────────┼───────────────┼──────────────────────────────────┤
│ 25122 │ Fix concurrent mode tests              │ rickhanlonii  │ merged   │ 18d 3h        │ https://github.com/facebook/re...│
├───────┼────────────────────────────────────────┼───────────────┼──────────┼───────────────┼──────────────────────────────────┤
│ 24863 │ Add startTransition API                │ bvaughn      │ merged   │ 14d 9h        │ https://github.com/facebook/re...│
└───────┴────────────────────────────────────────┴───────────────┴──────────┴───────────────┴──────────────────────────────────┘

Programmatic Usage

You can also use the tool programmatically in your Node.js applications:

const { main } = require('pr-duration-metrics-metrics');

// Call the main function directly
main().catch(err => {
  console.error('Error:', err);
  process.exit(1);
});

Use Cases

  • Identify bottlenecks in your code review process
  • Set team goals for PR resolution times
  • Track improvements in team velocity over time
  • Identify PRs that may be stuck or forgotten
  • Evaluate the effectiveness of PR process improvements

License

MIT © [Your Name]

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Related Projects