File tree Expand file tree Collapse file tree 2 files changed +24
-13
lines changed Expand file tree Collapse file tree 2 files changed +24
-13
lines changed Original file line number Diff line number Diff line change 3333 run : bundle install
3434 - name : Run benchmarks
3535 run : bundle exec rake
36- - name : Generate HTML page for all versions
36+ - name : Generate Markdown page for all versions
3737 run : bundle exec rake generate_versions_html
3838
3939 publish :
4343 - uses : actions/checkout@v3
4444 with :
4545 fetch-depth : 0
46- - name : Copy generated HTML page
46+ - name : Copy generated Markdown page
4747 run : |
4848 cp all_versions_benchmarks.html ./
4949 touch .nojekyll
5656 rm -rf *
5757 cp all_versions_benchmarks.html ./
5858 touch .nojekyll
59- - name : Commit and push HTML page
59+ - name : Commit and push Markdown page
6060 run : |
6161 git add .
6262 git commit -m "Update all versions benchmark HTML [ci skip]" || echo "No changes to commit"
Original file line number Diff line number Diff line change @@ -4,23 +4,34 @@ task :generate_versions_html do
44end
55desc "run benchmark in current ruby"
66task :run_benchmark do
7+ require 'fileutils'
78 if ENV [ 'CI' ] == '1'
8- system ( 'mkdir' , '-p' , 'reports' )
9- output_to_report = ">> reports/#{ RUBY_VERSION } .txt"
9+ FileUtils . mkdir_p ( "reports/#{ RUBY_VERSION } " )
1010 end
1111
12- Dir [ "code/*/*.rb" ] . sort_by { |path | path =~ /^code\/ general/ ? 0 : 1 } . each do |benchmark |
13- command = "ruby -v -W0 #{ benchmark } "
12+ benchmarks = Dir [ "code/*/*.rb" ] . sort_by { |path | path =~ /^code\/ general/ ? 0 : 1 }
1413
15- if ENV [ 'CI' ] == '1'
16- system ( "echo '$ ruby -v #{ benchmark } ' #{ output_to_report } " )
17- command += " #{ output_to_report } "
14+ if ENV [ 'CI' ] == '1'
15+ # Use GNU parallel if available, else fallback to Ruby threads
16+ parallel_cmd = "parallel --will-cite --halt soon,fail=1 --jobs $(( $(nproc) )) 'ruby -v -W0 {} > reports/#{ RUBY_VERSION } /{/.}.txt' ::: #{ benchmarks . join ( ' ' ) } "
17+ if system ( 'which parallel > /dev/null' )
18+ puts "Running benchmarks in parallel with GNU parallel"
19+ system ( parallel_cmd )
1820 else
21+ puts "GNU parallel not found, running benchmarks in Ruby threads"
22+ threads = benchmarks . map do |benchmark |
23+ Thread . new do
24+ out_file = "reports/#{ RUBY_VERSION } /#{ File . basename ( benchmark , '.rb' ) } .txt"
25+ system ( "ruby -v -W0 #{ benchmark } > #{ out_file } " )
26+ end
27+ end
28+ threads . each ( &:join )
29+ end
30+ else
31+ benchmarks . each do |benchmark |
1932 puts "$ ruby -v #{ benchmark } "
33+ system ( "ruby -v -W0 #{ benchmark } " )
2034 end
21-
22- puts command
23- system ( command )
2435 end
2536end
2637
You can’t perform that action at this time.
0 commit comments