Skip to content

Instantly share code, notes, and snippets.

@knightpop
Last active November 5, 2017 14:11
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 knightpop/c823aaeb2e44359dd8e6cc7db9e33162 to your computer and use it in GitHub Desktop.
Save knightpop/c823aaeb2e44359dd8e6cc7db9e33162 to your computer and use it in GitHub Desktop.
/**
* Just use for comprehension
*/
val start1: Instant = Instant.now
val fUserInfo1 = for {
nickname <- getNicknameById(userId)
emailAddr <- getEmailAddressByNickname(nickname)
accountInfo <- getAccountInfoByNickname(nickname)
} yield UserInfo(userId, nickname, emailAddr, accountInfo)
val userInfo1 = Await.result(fUserInfo1, 10 second)
val end1: Instant = Instant.now
println(printInterval(userInfo1, start1, end1)) // UserInfo(31337,ktz,helloworld@example.com,None) take 7 seconds
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment