shard-ameba/bench/check_sources.cr

31 lines
576 B
Crystal
Raw Normal View History

require "../src/ameba"
require "benchmark"
2017-11-13 21:20:22 +00:00
private def get_files(n)
Dir["src/**/*.cr"].first(n)
end
puts "== Compare:"
Benchmark.ips do |x|
[
1,
3,
5,
10,
20,
30,
40,
].each do |n|
2017-11-13 21:20:22 +00:00
config = Ameba::Config.load
config.formatter = Ameba::Formatter::BaseFormatter.new
config.files = get_files(n)
s = n == 1 ? "" : "s"
2017-11-13 21:20:22 +00:00
x.report("#{n} source#{s}") { Ameba.run config }
end
end
puts "== Measure:"
2017-11-17 22:13:14 +00:00
config = Ameba::Config.load
config.formatter = Ameba::Formatter::BaseFormatter.new
puts Benchmark.measure { Ameba.run config }