Skip to content

Commit 8fc4ac5

Browse files
committed
Add benchmarks.rb
`bundle exec ruby benchmarks.rb core/**/*.rbs`
1 parent ee5ccb0 commit 8fc4ac5

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

benchmarks.rb

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
require "rbs"
2+
require "benchmark/ips"
3+
require "csv"
4+
5+
results = []
6+
7+
ARGV.each do |file|
8+
GC.start
9+
10+
STDERR.puts "Benchmarking with #{file}..."
11+
content = File.read(file)
12+
13+
benchmark = Benchmark.ips do |x|
14+
x.report(file) do
15+
RBS::Parser.parse_signature(content)
16+
end
17+
18+
x.quiet = true
19+
end
20+
21+
results << {
22+
file: file,
23+
size: content.bytesize,
24+
ips: benchmark.entries[0].ips,
25+
sd: benchmark.entries[0].ips_sd
26+
}
27+
end
28+
29+
puts CSV.generate {|csv|
30+
csv << ["File", "Size", "IPS", "SD"]
31+
results.each do |result|
32+
csv << [result[:file], result[:size], result[:ips], result[:sd]]
33+
end
34+
}

0 commit comments

Comments
 (0)