如果在wordcount.scala中加入这一段
val starttime1 = System.currentTimeMillis()
val words = lines.flatMap(line => line.split(" "))
val stoptime1 = System.currentTimeMillis()
val between1 = stoptime1 - starttime1
println("flatmap time is :" + between1 + "ms")
between1指的是一个task执行flatmap的时间吗?
因为你没有对words的这个RDD做action操作[mw_shl_code=applescript,true] val starttime1 = System.currentTimeMillis()
println(starttime1)
val words = textrdd.flatMap(line => line.split(" "))
words.foreach(println)
val stoptime1 = System.currentTimeMillis()
val between1 = stoptime1 - starttime1
println(stoptime1)
println("flatmap time is :" + between1 + "ms")[/mw_shl_code]
你可以把他做一个action操作,并且放在开始和结束时间计算之间试试