mirror of
https://gitea.invidious.io/iv-org/shard-ameba.git
synced 2024-08-15 00:53:29 +00:00
closes #13 ``` $ crystal bench/check_sources.cr --release == Compare: 1 source 1.1k ( 907.18µs) (± 2.24%) fastest 3 sources 649.18 ( 1.54ms ) (± 2.26%) 1.70× slower 5 sources 196.85 ( 5.08ms ) (± 2.20%) 5.60× slower 10 sources 96.37 ( 10.38ms ) (± 2.06%) 11.44× slower 20 sources 58.88 ( 16.98ms ) (± 3.53%) 18.72× slower 30 sources 46.43 ( 21.54ms ) (± 3.38%) 23.74× slower 40 sources 46.19 ( 21.65ms ) (± 2.45%) 23.86× slower == Measure: 0.060000 0.040000 0.100000 ( 0.080935 ) ```
28 lines
458 B
Crystal
28 lines
458 B
Crystal
require "../src/ameba"
|
|
require "benchmark"
|
|
|
|
private def get_sources(n)
|
|
Dir["src/**/*.cr"].first(n)
|
|
end
|
|
|
|
puts "== Compare:"
|
|
Benchmark.ips do |x|
|
|
[
|
|
1,
|
|
3,
|
|
5,
|
|
10,
|
|
20,
|
|
30,
|
|
40,
|
|
].each do |n|
|
|
sources = get_sources(n)
|
|
formatter = Ameba::Formatter::BaseFormatter.new
|
|
s = n == 1 ? "" : "s"
|
|
x.report("#{n} source#{s}") { Ameba.run sources, formatter }
|
|
end
|
|
end
|
|
|
|
puts "== Measure:"
|
|
puts Benchmark.measure { Ameba.run }
|