[Native][tests] Log memory usage in Gradle build
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
import org.gradle.internal.util.NumberUtil.formatBytes
|
||||||
import org.jetbrains.kotlin.ideaExt.idea
|
import org.jetbrains.kotlin.ideaExt.idea
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
@@ -131,15 +132,32 @@ fun nativeTest(taskName: String, vararg tags: String) = projectTest(taskName, jU
|
|||||||
includeTags(*tags)
|
includeTags(*tags)
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.info(
|
fun formatExecutionParameters() = buildString {
|
||||||
buildString {
|
appendLine("$path parallel test execution parameters:")
|
||||||
appendLine("$path parallel test execution parameters:")
|
append(" Available CPU cores = $availableCpuCores")
|
||||||
append(" Available CPU cores = $availableCpuCores")
|
systemProperties.filterKeys { it.startsWith("junit.jupiter") }.toSortedMap().forEach { (key, value) ->
|
||||||
systemProperties.filterKeys { it.startsWith("junit.jupiter") }.toSortedMap().forEach { (key, value) ->
|
append("\n $key = $value")
|
||||||
append("\n $key = $value")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
)
|
}
|
||||||
|
|
||||||
|
fun formatMemoryUsage(before: Boolean) = buildString {
|
||||||
|
with(Runtime.getRuntime()) {
|
||||||
|
appendLine("$path (${if (before) "before" else "after"}) memory info:")
|
||||||
|
appendLine(" Max memory (-Xmx) = ${formatBytes(maxMemory())}")
|
||||||
|
appendLine(" Allocated memory = ${formatBytes(totalMemory())}")
|
||||||
|
appendLine(" Used memory = ${formatBytes(totalMemory() - freeMemory())}")
|
||||||
|
append(" Free memory = ${formatBytes(freeMemory())}")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
doFirst {
|
||||||
|
logger.info(formatExecutionParameters())
|
||||||
|
logger.info(formatMemoryUsage(before = true))
|
||||||
|
}
|
||||||
|
|
||||||
|
doLast {
|
||||||
|
logger.info(formatMemoryUsage(before = false))
|
||||||
|
}
|
||||||
} else
|
} else
|
||||||
doFirst {
|
doFirst {
|
||||||
throw GradleException(
|
throw GradleException(
|
||||||
|
|||||||
Reference in New Issue
Block a user