Skip to content

Instantly share code, notes, and snippets.

@cakper
Created November 2, 2018 17:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cakper/03f6b921f9dad09e4365490c2e234407 to your computer and use it in GitHub Desktop.
Save cakper/03f6b921f9dad09e4365490c2e234407 to your computer and use it in GitHub Desktop.
implicit class TaskExtenstions[A](val task: Task[A]) extends AnyVal {
def timed(): Task[A] = {
for {
startTime <- Task.eval(nanoTime())
result <- task.doOnFinish {
case _ => logger.info(nanoTime() - startTime)
}
} yield result
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment