forked from ankane/field_test
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
51 lines (45 loc) · 1.19 KB
/
Rakefile
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
require "bundler/gem_tasks"
require "rake/testtask"
require "rake/extensiontask"
task default: :test
Rake::TestTask.new do |t|
t.libs << "test"
t.pattern = "test/**/*_test.rb"
t.warning = false # mail gem
end
Rake::ExtensionTask.new("field_test") do |ext|
ext.name = "ext"
ext.lib_dir = "lib/field_test"
end
task :remove_ext do
path = "lib/field_test/ext.bundle"
File.unlink(path) if File.exist?(path)
end
Rake::Task["build"].enhance [:remove_ext]
task :benchmark do
require "benchmark/ips"
require "field_test"
Benchmark.ips do |x|
x.report("two variants") do
binary_test = FieldTest::BinaryTest.new
binary_test.add(1000, 900)
binary_test.add(800, 700)
binary_test.probabilities
end
x.report("three variants") do
binary_test = FieldTest::BinaryTest.new
binary_test.add(1000, 900)
binary_test.add(800, 700)
binary_test.add(600, 500)
binary_test.probabilities
end
x.report("four variants") do
binary_test = FieldTest::BinaryTest.new
binary_test.add(1000, 900)
binary_test.add(800, 700)
binary_test.add(600, 500)
binary_test.add(400, 300)
binary_test.probabilities
end
end
end