Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Gemfile-39
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
source 'https://rubygems.org'
gem 'rbs', "~> 3.9"
gem "benchmark-ips"
gem "csv"
20 changes: 20 additions & 0 deletions Gemfile-39.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
GEM
remote: https://rubygems.org/
specs:
benchmark-ips (2.14.0)
csv (3.3.5)
logger (1.7.0)
rbs (3.9.4)
logger

PLATFORMS
arm64-darwin-23
ruby

DEPENDENCIES
benchmark-ips
csv
rbs (~> 3.9)

BUNDLED WITH
2.6.3
8 changes: 8 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -537,3 +537,11 @@ task :compile_c99 do
ensure
ENV.delete("TEST_NO_C23")
end


task :prepare_bench do
ENV.delete("DEBUG")
Rake::Task[:"clobber"].invoke
Rake::Task[:"templates"].invoke
Rake::Task[:"compile"].invoke
end
11 changes: 11 additions & 0 deletions benchmark.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
require "bundler/setup"

require 'rbs'
require 'benchmark/ips'

sig = Pathname('/Users/soutaro/Downloads/activerecord-generated.rbs').read
Benchmark.ips do |x|
x.report("rbs v#{RBS::VERSION} parse activerecord-generated.rbs") do
RBS::Parser.parse_signature(sig)
end
end
35 changes: 35 additions & 0 deletions benchmarks.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
require "rbs"
require "benchmark/ips"
require "csv"

results = []

total = ARGV.size
ARGV.each_with_index do |file, index|
GC.start

STDERR.puts "#{index}/#{total}\tBenchmarking with #{file}..."
content = File.read(file)

benchmark = Benchmark.ips do |x|
x.report(file) do
RBS::Parser.parse_signature(content)
end

x.quiet = true
end

results << {
file: file,
size: content.bytesize,
ips: benchmark.entries[0].ips,
sd: benchmark.entries[0].ips_sd
}
end

puts CSV.generate {|csv|
csv << ["File", "Size", "IPS", "SD"]
results.each do |result|
csv << [result[:file], result[:size], result[:ips], result[:sd]]
end
}
Loading
Loading