Replies: 1 comment
-
To count the number of lines I would use def countLines(path: JPath): IO[Long] =
Files[IO]
.readUtf8Lines(Path.fromNioPath(path))
// .prefetch
.compile
.count If I wanted to count "," I wound use def count(path: JPath): IO[Int] =
Files[IO]
.readUtf8(Path.fromNioPath(path))
.map(_.count(_ == ','))
// .prefetch
.compile
.foldMonoid In both versions I would measure execution with and without prefetch. If I wanted to optimize reading from file I would also use Also, |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I wanted to test the performance of FS2 and was somewhat surprised by how much vanilla Java and Scala functions outperformed FS2. I have attached a simple test of reading and counting the number of lines below.
Code to reproduce:
For no. of lines in file = 5_000_000
This doesn't seem to scale any better for larger files either. Am I doing something wrong?
Beta Was this translation helpful? Give feedback.
All reactions