You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by da...@apache.org on 2016/02/23 16:56:13 UTC

spark git commit: [SPARK-13358] [SQL] Retrieve grep path when do benchmark

Repository: spark
Updated Branches:
  refs/heads/master e99d01709 -> 87d7f8904


[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 <vi...@gmail.com>

Closes #11231 from viirya/benchmark-grep-path.


Project: http://git-wip-us.apache.org/repos/asf/spark/repo
Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/87d7f890
Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/87d7f890
Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/87d7f890

Branch: refs/heads/master
Commit: 87d7f8904ad59d04099c3f1034834bc78ef59baf
Parents: e99d017
Author: Liang-Chi Hsieh <vi...@gmail.com>
Authored: Tue Feb 23 07:56:08 2016 -0800
Committer: Davies Liu <da...@gmail.com>
Committed: Tue Feb 23 07:56:08 2016 -0800

----------------------------------------------------------------------
 core/src/main/scala/org/apache/spark/util/Benchmark.scala | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/spark/blob/87d7f890/core/src/main/scala/org/apache/spark/util/Benchmark.scala
----------------------------------------------------------------------
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 39d1829..b562b58 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")
     }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@spark.apache.org
For additional commands, e-mail: commits-help@spark.apache.org