-
Notifications
You must be signed in to change notification settings - Fork 209
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
修正: cpu_num_threadsが未指定または0の場合に、論理コア数の半分をコアに渡すようにする (#1113)
* Add get_half_logical_cores func * Use get_half_logical_cores * Fix quote * Reset core_wrapper.py * Fix comment in initialize_cores * Fix README.md
- Loading branch information
Showing
4 changed files
with
31 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from unittest import TestCase | ||
from unittest.mock import patch | ||
|
||
from voicevox_engine.utility.core_utility import get_half_logical_cores | ||
|
||
|
||
class TestHalfLogicalCores(TestCase): | ||
@patch("os.cpu_count", return_value=8) | ||
def test_half_logical_cores_even(self, mock_cpu_count): | ||
self.assertEqual(get_half_logical_cores(), 4) | ||
|
||
@patch("os.cpu_count", return_value=9) | ||
def test_half_logical_cores_odd(self, mock_cpu_count): | ||
self.assertEqual(get_half_logical_cores(), 4) | ||
|
||
@patch("os.cpu_count", return_value=None) | ||
def test_half_logical_cores_none(self, mock_cpu_count): | ||
self.assertEqual(get_half_logical_cores(), 0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import os | ||
|
||
|
||
def get_half_logical_cores() -> int: | ||
logical_cores = os.cpu_count() | ||
if logical_cores is None: | ||
return 0 | ||
return logical_cores // 2 |