Git Product home page Git Product logo

benchmark's Introduction

Actions Status: MinGW Actions Status: RJIT Actions Status: Ubuntu Actions Status: Windows Travis Status

What is Ruby?

Ruby is an interpreted object-oriented programming language often used for web development. It also offers many scripting features to process plain text and serialized files, or manage system tasks. It is simple, straightforward, and extensible.

Features of Ruby

  • Simple Syntax
  • Normal Object-oriented Features (e.g. class, method calls)
  • Advanced Object-oriented Features (e.g. mix-in, singleton-method)
  • Operator Overloading
  • Exception Handling
  • Iterators and Closures
  • Garbage Collection
  • Dynamic Loading of Object Files (on some architectures)
  • Highly Portable (works on many Unix-like/POSIX compatible platforms as well as Windows, macOS, etc.) cf. https://docs.ruby-lang.org/en/master/maintainers_md.html#label-Platform+Maintainers

How to get Ruby

For a complete list of ways to install Ruby, including using third-party tools like rvm, see:

https://www.ruby-lang.org/en/downloads/

You can download release packages and the snapshot of the repository. If you want to download whole versions of Ruby, please visit https://www.ruby-lang.org/en/downloads/releases/.

Download with Git

The mirror of the Ruby source tree can be checked out with the following command:

$ git clone https://github.com/ruby/ruby.git

There are some other branches under development. Try the following command to see the list of branches:

$ git ls-remote https://github.com/ruby/ruby.git

You may also want to use https://git.ruby-lang.org/ruby.git (actual master of Ruby source) if you are a committer.

How to build

See Building Ruby

Ruby home page

https://www.ruby-lang.org/

Documentation

Mailing list

There is a mailing list to discuss Ruby. To subscribe to this list, please send the following phrase:

join

in the mail subject (not body) to the address [email protected].

Copying

See the file COPYING.

Feedback

Questions about the Ruby language can be asked on the Ruby-Talk mailing list or on websites like https://stackoverflow.com.

Bugs should be reported at https://bugs.ruby-lang.org. Read "Reporting Issues" for more information.

Contributing

See "Contributing to Ruby", which includes setup and build instructions.

The Author

Ruby was originally designed and developed by Yukihiro Matsumoto (Matz) in 1995.

[email protected]

benchmark's People

Contributors

akr avatar amatsuda avatar dependabot[bot] avatar drbrain avatar hsbt avatar k-tsj avatar keithrbennett avatar marcandre avatar nagachika avatar nobu avatar nurse avatar olleolleolle avatar rm155 avatar znz avatar

Stargazers

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

Watchers

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

benchmark's Issues

Add documentation to unit tests.

Sometimes documentation for unit tests is not necessary, but I have written some documentation for these tests that I think will be helpful for someone approaching it for the first time.

Add support for non-STDOUT streams

For methods that print to standard output (benchmark, bm, and bmbm), it would be nice to be able to specify that they go to another stream instead, such as an open file or a string buffer (StringIO), or even $stdout, in case it has been changed to something other than STDOUT.

In cases where the method signature would not support another parameter, an alternate method could be added in which the stream is a parameter, the body of the original method moved there, and the original method remaining to call the new method with STDOUT, e.g.:

def benchmark(caption = "", label_width = nil, format = nil, *labels)
  ...
end

...could become...

def benchmark_to(output_stream, caption = "", label_width = nil, format = nil, *labels)
  # body of original benchmark method
end

...and...

def benchmark(caption = "", label_width = nil, format = nil, *labels)
  benchmark_to(STDOUT, caption, label_width, format, *labels)
end

I believe all the likely objects for output would support puts, print, etc. I'm not sure about sync, but I suppose we could put a respond_to? guard around that call.

Make benchmarks nicer to read by default, via the commandline.

The ruby benchmark ecosystem is quite nice; it reports things, aka what is faster
aka more efficient.

Take the following old code I have:

# Interpolation is slowest, interestingly enough.
require 'benchmark'

N_TIMES = 5_000_000

a = 'foo'.freeze
b = 'bar'.freeze

Benchmark.bmbm(30) { |entry|
  entry.report('(1) interpol: #{a}#{b}  ') { N_TIMES.times { "#{a}#{b}" } }
  entry.report('(2) plus:     a+b       ') { N_TIMES.times { a + b      } }
  entry.report('(3) append:   a.dup << b') { N_TIMES.times { a.dup << b } }
}

Results are:

Rehearsal ------------------------------------------------------------------
(1) interpol: #{a}#{b}           0.534171   0.005792   0.539963 (  0.539974)
(2) plus:     a+b                0.419223   0.000000   0.419223 (  0.419227)
(3) append:   a.dup << b         0.413437   0.003269   0.416706 (  0.416715)
--------------------------------------------------------- total: 1.375892sec

                                     user     system      total        real
(1) interpol: #{a}#{b}           0.544134   0.006647   0.550781 (  0.550799)
(2) plus:     a+b                0.417118   0.000000   0.417118 (  0.417120)
(3) append:   a.dup << b         0.421809   0.013338   0.435147 (  0.435174)

Now from these results, it seems interpolation is slower than the other two
methods. I take it the most important is the very right value in () parens.

But I am not sure if I interprete this correctly.

Would it be possible for ruby to add a "verbose" output result, aka a
human-readable summary? With that I mean something like "did you
mean" gem, but adjusted to benchmark interpretation.

Something like:

"The above results indicate that interpolation (1) is fastest, whereas the
other two methods are -15% (2) and -14% (3) slower."

The above sentence should just indicate what I am trying to convey.

I'd like for benchmark to become more useful to normal people without
a PhD. Just like the did-you-mean gem, which is super-simple and
suggests what could be wrong. Sometimes this is not quite correct,
but most of the time did-you-mean is super-correct and easy to
understand. Benchmark evaluation are not so easy to understand
and I'd like a dedicated "report" subsystem there, that is human-readable.
Aka the output should be simpler, and using that subsystem in the
benchmarks module should ALSO be super-simple, even the default;
or, if not the default, then a simple option, a simple API, to call it,
such as:

Benchmark.bmbm(30, :be_verbose) { |entry|

Or API-wise:

Benchmark.verbose_bmbm(30) { |entry|
Benchmark.bmbm_verbose(30) { |entry|

Or some other, somewhat similar name.

If added then this should also be documented, at the least with one
usage example, so people can quickly start incorporating this into
their own benchmarks.

Add `Benchmark::Tms#to_h` method

Benchmark::Tms contains a to_a method, but a to_h method would also be useful. I added a to_h method, and a test for it.

When running the test, I found that the test was loading the benchmark code from the Ruby runtime (using require benchmark), so my code changes were ignored. The PR for this issue addresses this by using require_relative instead.

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.