我正在测量简单JSON的3-4毫秒序列化时间。这是AKKA所期望的性能,还是可以做些纠正的事情?
case class Response(msg: String)
implicit val format = jsonFormat(Response)
def logMagnet()(t: LoggingAdapter): HttpRequest => RouteResult => Unit = {
request => {
val startTime = System.currentTimeMillis()
response => {
val total = System.currentTimeMillis() - startTime
logger.info("took $total")
}
}
}
val route = logRequestResult(LoggingMagnet(logMagnet())) {
val start = System.currentTimeMillis()
val calculateSomethings = ....
val duration = System.currentTimeMillis() - start
val response = Response("took $duration to calculate")
complete(response)
}
对于琐碎的序列化,记录到响应之间的时间通常是3-4毫秒。