Skip to content

Commit eb0fe59

Browse files
committed
Update benchmark-parse.rb
1 parent df3600c commit eb0fe59

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

bin/benchmark-parse.rb

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,37 @@
22
require "benchmark/ips"
33
require "csv"
44

5+
require "optparse"
6+
7+
label = nil #: String?
8+
9+
OptionParser.new do |opts|
10+
opts.banner = "Usage: benchmark-parse.rb [options] [file|directory]..."
11+
12+
opts.on("--label=LABEL", "Set the benchmark label") do |v|
13+
label = v
14+
end
15+
end.parse!(ARGV)
16+
17+
file_names = []
518
files = {}
619
ARGV.each do |file|
20+
path = Pathname(file)
21+
if path.directory?
22+
Pathname.glob(path.join("**", "*.rbs")).each do |p|
23+
file_names << p.to_s
24+
end
25+
else
26+
file_names << path.to_s
27+
end
28+
end
29+
30+
file_names.uniq.each do |file|
731
content = File.read(file)
832
files[file] = RBS::Buffer.new(content: content, name: Pathname(file))
933
end
1034

11-
puts "Benchmarking parsing #{files.size} files..."
35+
puts "Benchmarking RBS(#{RBS::VERSION} in #{Bundler.default_gemfile.basename}#{label ? " (#{label})" : ""}) parsing with #{files.size} files..."
1236

1337
result = Benchmark.ips do |x|
1438
x.report("parsing") do

0 commit comments

Comments
 (0)