bencher

0.1.1 Latest release Yanked release released
spoved/bencher.cr
1

This repo seems to be no longer available at spoved/bencher.cr.

Git synchronization failed . Last successful sync was .

Help find it again! … or have it archived.

bencher

Bencher is a extension to help gather runtime data on your application. It will report the execution time of all methods in the program. This is very much experimental.

Installation

Add this to your application's shard.yml:

development_dependencies:
  bencher:
    github: spoved/bencher.cr

Usage

To get the most out of bencher, you must require it before any other libraries. I also suggest it be wrapped in a compile time flag so it will not be introduced in production or non-test binaries.

{% if flag?(:benchmark) %}
  require "bencher"
{% end %}

# Other libraries
require "json"
require "uuid"

Thats it! Simply build with the --release -Dbenchmark options and on exit, a report of all the method calls and the time it took to execute will be printed to SDTOUT.

If you want to write the report to file, there are a couple ENVs you can set:

env | description | default ---|---|--- BENCHER_RAW_FILE | Path to save the raw metrics and data too | nil BENCHER_REPORT | Path to save the report output too | STDOUT BENCHER_FORMAT | Format of the report (csv or json) | csv

A simple bash wrapper could look like this:

#!/usr/bin/env bash

test_dir=${HOME}/Desktop/bencher_tests

export BENCHER_RAW_FILE=${test_dir}/bencher_raw.json
export BENCHER_REPORT=${test_dir}/bencher.csv
export BENCHER_FORMAT=csv

crystal build --release -Dbenchmark ./src/main.cr -o ./bin/main

./bin/main

You could then find the report output in ${HOME}/Desktop/bencher_tests

Contributing

  1. Fork it (https://github.com/spoved/bencher.cr/fork)
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Contributors

bencher:
  github: spoved/bencher.cr
  version: ~> 0.1.1
License MIT
Crystal 0.30.0

Authors

Dependencies 0

Development Dependencies 0

Dependents 0

Last synced .
search fire star recently