我想让我的Spark程序执行速度有时间,但由于懒惰,这是相当困难的。让我们考虑到这里本(意义)代码:如何计时Spark程序执行速度
var graph = GraphLoader.edgeListFile(context, args(0))
val graph_degs = graph.outerJoinVertices(graph.degrees).triplets.cache
/* I'd need to start the timer here */
val t1 = System.currentTimeMillis
val edges = graph_degs.flatMap(trip => { /* do something*/ })
.union(graph_degs)
val count = edges.count
val t2 = System.currentTimeMillis
/* I'd need to stop the timer here */
println("It took " + t2-t1 + " to count " + count)
的事情是,转换是懒洋洋地所以没有什么被前val count = edges.count
行评估。但根据我的观点,t1
获得一个值,尽管上面的代码没有值......在定时器启动后,即使在代码中的位置,在t1
以上的代码也被评估。这是一个问题...
在Spark Web UI中,我找不到任何有趣的内容,因为我需要花费特定代码行后的时间。你认为有一个简单的解决方案,看看什么时候一组转化得到真正的评估?
的可能的复制[如何分析在Scala中的方法?](http://stackoverflow.com/questions/9160001/how-to-profile-methods-in-scala) –
看起来不像重复,因为这篇文章是特定于Apache Spark,它提供了特定的测量工具,并呈现特定的性能分析挑战 - 就像这里所描述的那样:评估是懒惰的,并且存在重新评估的代码块可能不代表测量的操作。 –