1.2.3

## How-To - Write Benchmarks

This page was machine translated. Please help us improve it.

See How-To - Translate Documentation

Why benchmarks?

Benchmarks are a great tool for comparing Rubinius with the rest of the Ruby runtimes, i.e. MRI, JRuby, IronRuby and other implementations. It is not so much intended to measure Rubinius itself so if you want to contribute writing benchmarks make sure to follow these steps:

1. Find existing benchmarks in rubinius/benchmarks and study their layout.
2. Each benchmark file should measure one specific aspect of Ruby. For example different ways of deleting keys/values from a Hash.
3. Use the benchmark framework.
4. Keep the benchmarks short and simple.
5. The benchmarks are not meant to measure Rubinius. So if you’re writing a benchmark for a class with bang and no-bang methods you will want to use a duplicate of a variable in the bang method but you don’t need to dup in the no-bang method.

If you want to test a benchmark you can run it file or even directory wise:

    bin/benchmark benchmark/core/string/bench_case.rb
    bin/benchmark benchmark/core