Giter Club home page Giter Club logo

benchpress's Introduction

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

benchpress's People

Contributors

baweaver avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

benchpress's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.