bundler-timing-plugin
Bundler plugin that displays the elapsed time of each gem fetch and install during bundle install. It also prints the elapsed time of git source fetches.
Requirements
Bundler 4.1.0.dev or higher. Earlier Bundler versions do not emit the before-fetch/after-fetch/before-git-fetch/after-git-fetch hooks this plugin relies on.
Installation
Install the plugin globally:
$ bundler plugin install bundler-timing-plugin
Or declare it in your Gemfile:
plugin "bundler-timing-plugin"
Usage
Once installed, the plugin is fully automatic. Running bundle install will print one line per gem download, install, and git source fetch:
$ bundle install
Fetching gem metadata from https://rubygems.org/...
Downloaded rails in: 0.482s
Installed rails in: 0.137s
Downloaded rake in: 0.094s
Installed rake in: 0.066s
Fetched https://github.com/example/my_gem.git in: 1.203s
Gems that are already fully cached and skip the download step only emit the install line. If a gem install fails, the timing line for that gem is omitted.
How it works
The plugin registers six Bundler plugin hooks and uses Process::CLOCK_MONOTONIC to measure elapsed time:
| Hook | Use |
|---|---|
before-fetch / after-fetch |
Time Source::Rubygems#download_gem |
before-install / after-install |
Time ParallelInstaller install per gem |
before-git-fetch / after-git-fetch |
Time Source::Git fetch and checkout |
State is held in a Mutex-protected hash so the plugin is safe under Bundler's parallel installer.