All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.zink.scala.fly.stats.StatsPrinter.scala Maven / Gradle / Ivy

Go to download

Fly Scala is a scala client library for working with a Fly Server. Fly is an object space server that is specifically written to provide lightweight object based messaging between computers running on a network. This distribution does not contain the server, please go to http://www.flyobjectspace.com/ for the server that matches the version of Fly Scala you want to use.

The newest version!
package com.zink.scala.fly.stats

object StatsPrinter {
  def writeHeader(beans: Seq[StatsBean]) {
    println("\n====")
    println(pad("Entry Name", nameColumnWidth(beans)) + "Writes\tReads\tTakes\tNotifies")
  }

  def writeStats(beans: Seq[StatsBean]) {
    val columnWidth = nameColumnWidth(beans)
    for (bean <- beans) {
      print(pad(bean.typeName, columnWidth))
      print(bean.writes)
      print("\t" + bean.totalReads)
      print("\t" + bean.totalTakes)
      println("\t" + bean.notifyWriteTmpls + bean.notifyTakeTmpls)
    }
  }

  def pad(s: String, width: Int): String = s + " " * (width - s.length)

  private def nameColumnWidth(beans: Seq[StatsBean]): Int = (0 /: beans){(m: Int, bean: StatsBean) => m.max(bean.typeName.length())} + 4
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy