File tree Expand file tree Collapse file tree 2 files changed +13
-7
lines changed
Expand file tree Collapse file tree 2 files changed +13
-7
lines changed Original file line number Diff line number Diff line change @@ -43,11 +43,16 @@ def jobs
4343 private
4444
4545 def balance_jobs ( bucket_count :, timed_files :, untimed_files :)
46- balance_by ( bucket_count , timed_files , &:last )
47- . map { |bucket | bucket . map ( &:first ) }
48- . zip (
49- round_robin ( bucket_count , untimed_files )
50- ) . map ( &:flatten )
46+ timed_groups = balance_by ( bucket_count , timed_files , &:last )
47+ . map { |bucket | bucket . map ( &:first ) }
48+ untimed_groups = round_robin ( bucket_count , untimed_files )
49+
50+ # When the files can't be evenly divided between groups, the first groups
51+ # in each of timed_groups & untimed_groups will have more files.
52+ # By reversing one of them before combining them, we can improve the final distribution.
53+ timed_groups
54+ . zip ( untimed_groups . reverse )
55+ . map ( &:flatten )
5156 . reject ( &:empty? )
5257 . map { |files | Job . new ( files , args ) }
5358 end
Original file line number Diff line number Diff line change 8080 it "doesn't return empty job-groups" do
8181 expect ( subject ) . to match_array (
8282 [
83- have_attributes ( id : include ( './slow_spec.rb' , './new_1_spec.rb' ) ) ,
84- have_attributes ( id : include ( './fast_1_spec.rb' ) )
83+ have_attributes ( id : include ( './fast_1_spec.rb' ) ) ,
84+ have_attributes ( id : include ( './slow_spec.rb' ) ) ,
85+ have_attributes ( id : include ( './new_1_spec.rb' ) )
8586 ]
8687 )
8788 end
You can’t perform that action at this time.
0 commit comments