Socket
Book a DemoInstallSign in
Socket

benchpress

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

benchpress

1.1.0
bundlerRubygems
Version published
Maintainers
1
Created
Source

Benchpress

Code Climate

Pit a few ruby methods against eachother, and chart it for great glory.

Props to the folks at Gruff (https://github.com/topfunky/gruff) for making this simpler to do, and to the Ruby team behind Benchmark.

How to Benchpress

We're going to need to define a chart.

c = Benchpress::Chart.new(
  entities: {
    string: -> { 'string' },
    symbol: -> { :symbol  }
  },
  min: 50_000,               # Minimum times to run. Default: 0
  max: 100_000,              # Maximum times to run. Default: 1_000
  step: 10_000,              # Step rate for next benchmark. Default: 250
  cycles: 3,                 # How many times to repeat, so as to get an average. Default: 1
  name: 'string_vs_symbol',  # File name. Default: 'Time.now.strftime '%Y-%m-%d-%H:%M:%S''
  format: 'png'              # File format. Default: png
)

and then render it:

c.render # Line chart

c.render :line # Line chart
c.render :bar  # Bar chart

Voila! Instant chart with realtime benchmarks to demonstrate complexities of methods everywhere! Supports an arbitrary number of entities.

Want something a tinge more beefy and realistic? How about parsing 9 megs of JSON?

c = Benchpress::Chart.new(
  entities: {
    oj: -> { Oj.load json },
    json: -> { JSON.load json}
  },
  max: 10,
  step: 2,
  name: '9m-json-bar'
)

c.render :bar

FAQs

Package last updated on 28 Jan 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.