Sha256: cb99abbcd5703f981372031dfcacf5a72cc1db7ddf615109a1018b9166388602
Contents?: true
Size: 1.02 KB
Versions: 40
Compression:
Stored size: 1.02 KB
Contents
#!/usr/bin/env ruby # frozen_string_literal: true require "bundler/inline" gemfile do source "https://rubygems.org" gem "benchmark-ips" gem "parser", require: "parser/current" gem "ruby_parser" end $:.unshift(File.expand_path("../lib", __dir__)) require "syntax_tree" def compare(filepath) prefix = "#{File.expand_path("..", __dir__)}/" puts "=== #{filepath.delete_prefix(prefix)} ===" source = File.read(filepath) Benchmark.ips do |x| x.report("syntax_tree") { SyntaxTree.parse(source) } x.report("parser") { Parser::CurrentRuby.parse(source) } x.report("ruby_parser") { RubyParser.new.parse(source) } x.compare! end end filepaths = ARGV # If the user didn't supply any files to parse to benchmark, then we're going to # default to parsing this file and the main syntax_tree file (a small and large # file). if filepaths.empty? filepaths = [ File.expand_path("bench", __dir__), File.expand_path("../lib/syntax_tree/node.rb", __dir__) ] end filepaths.each { |filepath| compare(filepath) }
Version data entries
40 entries across 40 versions & 1 rubygems