0
0
mirror of https://github.com/ankidroid/Anki-Android.git synced 2024-09-20 03:52:15 +02:00

feat: Speed up tests on M1 Macs

M1 Macs don't have SMT, so there's no need to halve the processors when
running tests

Before:
BUILD SUCCESSFUL in 3m 1s
BUILD SUCCESSFUL in 2m 57s

After:
BUILD SUCCESSFUL in 2m 08s
BUILD SUCCESSFUL in 1m 53s
This commit is contained in:
David Allison 2022-05-13 18:35:46 +01:00 committed by Mike Hardy
parent 05b96990ce
commit fcdb08fe24

View File

@ -121,7 +121,11 @@ ext {
// Virtualized Environment like CI may report host CPU counts vs guest, but runs 2 cores
// everyone else gets 50% of cores to account for SMT which doesn't help this workload
gradleTestMaxParallelForks = 1
if (!ciBuild) {
if (System.getProperty("os.name") == "Mac OS X") {
// macOS reports hardware cores. This is accurate for CI, Intel (halved due to SMT) and Apple Silicon
gradleTestMaxParallelForks = "sysctl -n hw.physicalcpu".execute().text.toInteger()
} else if (!ciBuild) {
// Use 50% of cores to account for SMT which doesn't help this workload
gradleTestMaxParallelForks = Runtime.runtime.availableProcessors().intdiv(2) ?: 1
}
}