Skip to content

Commit 2d1e9e0

Browse files
committed
Add profile script
1 parent d2dcce7 commit 2d1e9e0

File tree

5 files changed

+26
-1
lines changed

5 files changed

+26
-1
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
test.rb
2+
profile.json

Gemfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@ source "https://rubygems.org"
55
gemspec
66

77
gem "prism"
8+
gem "vernier"
9+
gem "profile-viewer"

Gemfile.lock

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,24 @@ PATH
88
GEM
99
remote: https://rubygems.org/
1010
specs:
11+
optparse (0.5.0)
1112
prettier_print (1.2.1)
1213
prism (0.30.0)
14+
profile-viewer (0.0.2)
15+
optparse
16+
webrick
17+
vernier (1.0.1)
18+
webrick (1.8.1)
1319

1420
PLATFORMS
1521
arm64-darwin-22
1622
arm64-darwin-23
1723

1824
DEPENDENCIES
1925
prism
26+
profile-viewer
2027
syntax_tree-prism!
28+
vernier
2129

2230
BUNDLED WITH
2331
2.4.13

bin/bench

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ require "benchmark"
77
$:.unshift(File.expand_path("../lib", __dir__))
88
require "syntax_tree/prism"
99

10-
filepaths = Dir[File.expand_path("../../ruby/prism/test/prism/fixtures/**/*.txt")]
10+
filepaths = Dir[File.expand_path("../../rails/rails/activerecord/**/*.rb")]
11+
puts "Formatting #{filepaths.length} files"
1112

1213
Benchmark.bmbm do |x|
1314
x.report("format") do

bin/profile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/usr/bin/env ruby
2+
# frozen_string_literal: true
3+
4+
require "bundler/setup"
5+
require "vernier"
6+
7+
$:.unshift(File.expand_path("../lib", __dir__))
8+
require "syntax_tree/prism"
9+
10+
results = Dir[File.expand_path("../../rails/rails/activerecord/**/*.rb")].map { |filepath| Prism.parse_file(filepath) }
11+
puts "Profiling #{results.length} files"
12+
13+
Vernier.trace(out: "profile.json") { results.each(&:format) }

0 commit comments

Comments
 (0)