diff options
author | Liang-Chi Hsieh <viirya@gmail.com> | 2016-02-23 07:56:08 -0800 |
---|---|---|
committer | Davies Liu <davies.liu@gmail.com> | 2016-02-23 07:56:08 -0800 |
commit | 87d7f8904ad59d04099c3f1034834bc78ef59baf (patch) | |
tree | d201cc5df5c420754d18a01218d09be4c0d85f33 | |
parent | e99d0170982b06676110906db4de6196586829f6 (diff) | |
download | spark-87d7f8904ad59d04099c3f1034834bc78ef59baf.tar.gz spark-87d7f8904ad59d04099c3f1034834bc78ef59baf.tar.bz2 spark-87d7f8904ad59d04099c3f1034834bc78ef59baf.zip |
[SPARK-13358] [SQL] Retrieve grep path when do benchmark
JIRA: https://issues.apache.org/jira/browse/SPARK-13358
When trying to run a benchmark, I found that on my Ubuntu linux grep is not in /usr/bin/ but /bin/. So wondering if it is better to use which to retrieve grep path.
cc davies
Author: Liang-Chi Hsieh <viirya@gmail.com>
Closes #11231 from viirya/benchmark-grep-path.
-rw-r--r-- | core/src/main/scala/org/apache/spark/util/Benchmark.scala | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/core/src/main/scala/org/apache/spark/util/Benchmark.scala b/core/src/main/scala/org/apache/spark/util/Benchmark.scala index 39d1829310..b562b58f1b 100644 --- a/core/src/main/scala/org/apache/spark/util/Benchmark.scala +++ b/core/src/main/scala/org/apache/spark/util/Benchmark.scala @@ -19,6 +19,7 @@ package org.apache.spark.util import scala.collection.mutable import scala.collection.mutable.ArrayBuffer +import scala.util.Try import org.apache.commons.lang3.SystemUtils @@ -93,7 +94,10 @@ private[spark] object Benchmark { if (SystemUtils.IS_OS_MAC_OSX) { Utils.executeAndGetOutput(Seq("/usr/sbin/sysctl", "-n", "machdep.cpu.brand_string")) } else if (SystemUtils.IS_OS_LINUX) { - Utils.executeAndGetOutput(Seq("/usr/bin/grep", "-m", "1", "\"model name\"", "/proc/cpuinfo")) + Try { + val grepPath = Utils.executeAndGetOutput(Seq("which", "grep")) + Utils.executeAndGetOutput(Seq(grepPath, "-m", "1", "model name", "/proc/cpuinfo")) + }.getOrElse("Unknown processor") } else { System.getenv("PROCESSOR_IDENTIFIER") } |