我该如何加速以下的
(关于另一个问题的后续参考)
scalaz-stream
代码?目前处理70MB文本大约需要5分钟,因此我可能做错了什么,因为普通的scala等效代码只需要几秒钟。(关于另一个问题的后续参考)
val converter2: Task[Unit] = {
val docSep = "~~~"
io.linesR("myInput.txt")
.flatMap(line => { val words = line.split(" ");
if (words.length==0 || words(0)!=docSep) Process(line)
else Process(docSep, words.tail.mkString(" ")) })
.split(_ == docSep)
.filter(_ != Vector())
.map(lines => lines.head + ": " + lines.tail.mkString(" "))
.intersperse("\n")
.pipe(text.utf8Encode)
.to(io.fileChunkW("correctButSlowOutput.txt"))
.run
}
io.linesR
和.to(io.fileChunkW...)
部分没有使用缓冲流? - Dylan