mirror of
https://mirror.ghproxy.com/https://github.com/StarCitizenToolBox/app.git
synced 2024-12-23 05:23:44 +08:00
修复 Affinity 计算
This commit is contained in:
parent
e8a58a9c42
commit
3f637f4aef
@ -218,9 +218,26 @@ foreach ($adapter in $adapterMemory) {
|
|||||||
return int.tryParse(cpuNumberResult.stdout.toString().trim()) ?? 0;
|
return int.tryParse(cpuNumberResult.stdout.toString().trim()) ?? 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<int?> getCpuAffinity(int eCoreCount) async {
|
static Future<String?> getCpuAffinity(int eCoreCount) async {
|
||||||
final cpuNumber = await getNumberOfLogicalProcessors();
|
final cpuNumber = await getNumberOfLogicalProcessors();
|
||||||
if (cpuNumber == 0) return null;
|
if (cpuNumber == 0 || eCoreCount == 0 || eCoreCount > cpuNumber) {
|
||||||
return (1 << cpuNumber) - (1 << eCoreCount);
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
StringBuffer sb = StringBuffer();
|
||||||
|
for (var i = 0; i < cpuNumber; i++) {
|
||||||
|
if (i < eCoreCount) {
|
||||||
|
sb.write("0");
|
||||||
|
} else {
|
||||||
|
sb.write("1");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
final binaryString = sb.toString();
|
||||||
|
int hexDigits = (binaryString.length / 4).ceil();
|
||||||
|
dPrint("Affinity sb ==== $sb");
|
||||||
|
return int.parse(binaryString, radix: 2)
|
||||||
|
.toRadixString(16)
|
||||||
|
.padLeft(hexDigits, '0')
|
||||||
|
.toUpperCase();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -527,7 +527,7 @@ class HomeUIModel extends BaseUIModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
doLaunchGame(String launchExe, List<String> args, String installPath,
|
doLaunchGame(String launchExe, List<String> args, String installPath,
|
||||||
int? processorAffinity) async {
|
String? processorAffinity) async {
|
||||||
_isGameRunning[installPath] = true;
|
_isGameRunning[installPath] = true;
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
try {
|
try {
|
||||||
@ -537,13 +537,14 @@ class HomeUIModel extends BaseUIModel {
|
|||||||
dPrint('stdout: ${result.stdout}');
|
dPrint('stdout: ${result.stdout}');
|
||||||
dPrint('stderr: ${result.stderr}');
|
dPrint('stderr: ${result.stderr}');
|
||||||
} else {
|
} else {
|
||||||
|
dPrint("set Affinity === $processorAffinity ");
|
||||||
ProcessResult result = await Process.run("cmd.exe", [
|
ProcessResult result = await Process.run("cmd.exe", [
|
||||||
'/C',
|
'/C',
|
||||||
'Start',
|
'Start',
|
||||||
'"StarCitizen"',
|
'"StarCitizen"',
|
||||||
'/High',
|
'/High',
|
||||||
'/Affinity',
|
'/Affinity',
|
||||||
'$processorAffinity',
|
processorAffinity,
|
||||||
launchExe,
|
launchExe,
|
||||||
...args
|
...args
|
||||||
]);
|
]);
|
||||||
|
Loading…
Reference in New Issue
Block a user