public DynamicThrottlePolicy setWeight(double weight) {
        this.weight = Math.pow(weight, 0.5);
        return this;
    }
@Test
    void twoWeightedPoliciesWithUnboundedTaskQueue() {
        for (int repeat = 0; repeat < 3; repeat++) {
            long operations = 1_000_000;
            int workPerSuccess = 6 + (int) (30 * Math.random());
            int numberOfWorkers = 1 + (int) (10 * Math.random());
            int maximumTasksPerWorker = 100_000;
            int workerParallelism = 32;
            ManualTimer timer = new ManualTimer();
            DynamicThrottlePolicy policy1 = new DynamicThrottlePolicy(timer);
            DynamicThrottlePolicy policy2 = new DynamicThrottlePolicy(timer).setWeight(0.5);
            Summary summary = run(operations, workPerSuccess, numberOfWorkers, maximumTasksPerWorker, workerParallelism, timer, policy1, policy2);

            double minMaxPending = numberOfWorkers * workerParallelism;
            double maxMaxPending = numberOfWorkers * maximumTasksPerWorker;
            assertInRange(minMaxPending, summary.averagePending, maxMaxPending);
            // Actual shares are not distributed perfectly proportionally to weights, but close enough.
            assertInRange(minMaxPending * 0.6, summary.averageWindows[0], maxMaxPending * 0.6);
            assertInRange(minMaxPending * 0.4, summary.averageWindows[1], maxMaxPending * 0.4);
            assertInRange(1, summary.inefficiency, 1.02);
            assertInRange(0, summary.waste, 0);
        }
    }