Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions core/src/main/scala/org/apache/spark/util/Benchmark.scala
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,27 @@ private[spark] object Benchmark {
Utils.executeAndGetOutput(Seq("/usr/sbin/sysctl", "-n", "machdep.cpu.brand_string"))
} else if (SystemUtils.IS_OS_LINUX) {
Try {
val arch = SystemUtils.OS_ARCH
val cpuinfo = "/proc/cpuinfo"
val grepPath = Utils.executeAndGetOutput(Seq("which", "grep")).stripLineEnd
Utils.executeAndGetOutput(Seq(grepPath, "-m", "1", "model name", "/proc/cpuinfo"))
.stripLineEnd.replaceFirst("model name[\\s*]:[\\s*]", "")
if (arch.startsWith("x86")) {
Utils.executeAndGetOutput(Seq(grepPath, "-m", "1", "model name", cpuinfo))
.stripLineEnd.replaceFirst("model name[\\s*]:[\\s*]", "")
} else if (arch.startsWith("ppc")) {
val cpu = Utils.executeAndGetOutput(Seq(grepPath, "-m", "1", "cpu", cpuinfo))
.stripLineEnd.replaceFirst("cpu\\s*:\\s*", "")
val clock = Utils.executeAndGetOutput(Seq(grepPath, "-m", "1", "clock", cpuinfo))
.stripLineEnd.replaceFirst("clock\\s*:\\s*", "")
s"$cpu @ $clock"
} else if (arch.startsWith("s390")) {
val cpu = Utils.executeAndGetOutput(Seq(grepPath, "-m", "1", "vendor_id", cpuinfo))
.stripLineEnd.replaceFirst("vendor_id\\s*:\\s*", "")
val machine = Utils.executeAndGetOutput(Seq(grepPath, "-m", "1", "machine", cpuinfo))
.stripLineEnd.replaceFirst("processor \\d*: version = \\d*,\\s*", "")
s"$cpu, $machine"
} else {
"Unknown processor"
}
}.getOrElse("Unknown processor")
} else {
System.getenv("PROCESSOR_IDENTIFIER")
Expand Down