-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathRakefile
58 lines (46 loc) · 1.37 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
52
53
54
55
56
57
require 'rake/extensiontask'
require "rspec/core/rake_task"
Rake::ExtensionTask.new('qrencoder_ext') do |ext|
ext.lib_dir = 'lib/qrencoder'
end
RSpec::Core::RakeTask.new
task :default => [:clean, :compile, :spec]
require 'rake/rdoctask'
require 'sdoc'
Rake::RDocTask.new do |rdoc|
rdoc.rdoc_dir = 'rdoc'
rdoc.options << '--fmt' << 'shtml' # explictly set shtml generator
rdoc.template = 'direct' # lighter template used on railsapi.com
rdoc.title = "qrencoder"
rdoc.main = "README.rdoc"
rdoc.rdoc_files.include('README.rdoc')
rdoc.rdoc_files.include('lib/**/*.rb')
rdoc.rdoc_files.include('ext/**/*.c')
end
desc "Benchmark C implementation against pure Ruby implementation (from rqrcode)"
task(:benchmark => [:clean, :compile]) do
require 'rubygems'
require 'benchmark'
require 'bundler/setup'
Bundler.require(:benchmark)
require 'qrencoder'
require 'rqrcode'
Benchmark.bmbm do |benchmark|
num = 100
benchmark.report("rqrcode #{num}") do
num.times do |i|
RQRCode::QRCode.new("string #{i}").modules
end
end
benchmark.report("qrencoder #{num}") do
num.times do |i|
QREncoder.encode("string #{i}", :correction => :high).data
end
end
benchmark.report("qrencoder 100_000") do
100_000.times do |i|
QREncoder.encode("string #{i}", :correction => :high).data
end
end
end
end