47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
# File 'lib/binpacker/scheduler.rb', line 47
def partition(tests:, worker_count:, timings:)
sorted = sorted_by_weight(tests, timings)
upper = lpt_makespan(sorted, worker_count, timings)
lower = [max_weight(sorted, timings), total_weight(sorted, timings) / worker_count.to_f].max
best_queues = nil
ITERATIONS.times do
mid = (upper + lower) / 2.0
queues = first_fit_decreasing(sorted, worker_count, mid, timings)
if queues
best_queues = queues
upper = mid
else
lower = mid
end
end
best_queues || LptScheduler.new.partition(tests: tests, worker_count: worker_count, timings: timings)
end
|