File: Rakefile

package info (click to toggle)
ruby-mini-histogram 0.1.3-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 132 kB
  • sloc: ruby: 139; sh: 4; makefile: 4
file content (36 lines) | stat: -rw-r--r-- 758 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
require "bundler/gem_tasks"
require "rake/testtask"

$LOAD_PATH.unshift File.expand_path("./lib", __dir__)

Rake::TestTask.new(:test) do |t|
  t.libs << "test"
  t.libs << "lib"
  t.test_files = FileList["test/**/*_test.rb"]
end

task :default => :test


task :bench do
  require 'benchmark/ips'
  require 'enumerable/statistics'
  require 'mini_histogram'

  array = 1000.times.map { rand }

  histogram = MiniHistogram.new(array)
  my_weights = histogram.weights
  puts array.histogram.weights == my_weights
  puts array.histogram.weights.inspect
  puts my_weights.inspect


  Benchmark.ips do |x|
    x.report("enumerable stats") { array.histogram }
    x.report("mini histogram  ") {
      MiniHistogram.new(array).weights
    }
    x.compare!
  end
end