helper-thread-params.js (1008B)
1 // |jit-test| skip-if: helperThreadCount() === 0 2 3 function assertError(thunk) { 4 let threw = false; 5 try { 6 thunk(); 7 } catch (e) { 8 threw = true; 9 } 10 assertEq(threw, true); 11 } 12 13 let initialHelperThreads = helperThreadCount(); 14 15 // Test that setting maxHelperThreads limits the number of threads. 16 gcparam("helperThreadRatio", 100); 17 for (let i = 1; i <= initialHelperThreads; i++) { 18 gcparam("maxHelperThreads", i); 19 assertEq(gcparam("helperThreadCount"), i); 20 } 21 22 // Test that setting helperThreadRatio works as expected. 23 gcparam("maxHelperThreads", 1000); 24 for (let i = 25; i <= 400; i *= 2) { 25 gcparam("helperThreadRatio", i); 26 let ratio = i / 100; 27 let expected = Math.max(Math.floor(initialHelperThreads * ratio), 1); 28 assertEq(gcparam("helperThreadCount"), expected); 29 assertEq(helperThreadCount(), Math.max(initialHelperThreads, expected)); 30 } 31 32 // Test that illegal settings are checked. 33 assertError(() => gcparam("helperThreadRatio", 0)); 34 assertError(() => gcparam("maxHelperThreads", 0));