Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 2 of 2 for chunkSizeFor (0.26 sec)

  1. pkg/scheduler/framework/parallelize/parallelism.go

    func NewParallelizer(p int) Parallelizer {
    	return Parallelizer{parallelism: p}
    }
    
    // chunkSizeFor returns a chunk size for the given number of items to use for
    // parallel work. The size aims to produce good CPU utilization.
    // returns max(1, min(sqrt(n), n/Parallelism))
    func chunkSizeFor(n, parallelism int) int {
    	s := int(math.Sqrt(float64(n)))
    
    	if r := n/parallelism + 1; s > r {
    		s = r
    Registered: Sat Jun 15 01:39:40 UTC 2024
    - Last Modified: Thu Mar 09 17:12:30 UTC 2023
    - 2K bytes
    - Viewed (0)
  2. pkg/scheduler/framework/parallelize/parallelism_test.go

    		{
    			input:      0,
    			wantOutput: 1,
    		},
    	}
    
    	for _, test := range tests {
    		t.Run(fmt.Sprintf("%d", test.input), func(t *testing.T) {
    			if chunkSizeFor(test.input, DefaultParallelism) != test.wantOutput {
    				t.Errorf("Expected: %d, got: %d", test.wantOutput, chunkSizeFor(test.input, DefaultParallelism))
    			}
    		})
    	}
    Registered: Sat Jun 15 01:39:40 UTC 2024
    - Last Modified: Wed Oct 20 17:39:23 UTC 2021
    - 1.2K bytes
    - Viewed (0)
Back to top