src/Pure/General/timing.scala
author blanchet
Thu, 16 Dec 2010 22:45:02 +0100
changeset 41220 4d11b0de7dd8
parent 40852 aee98c88c587
child 44699 5199ee17c7d7
permissions -rw-r--r--
discriminate SMT errors a bit better

/*  Title:      Pure/General/timing.scala
    Author:     Makarius

Basic support for time measurement.
*/

package isabelle

object Time
{
  def seconds(s: Double): Time = new Time((s * 1000.0) round)
}

class Time(val ms: Long)
{
  def seconds: Double = ms / 1000.0

  def min(t: Time): Time = if (ms < t.ms) this else t
  def max(t: Time): Time = if (ms > t.ms) this else t

  override def toString =
    String.format(java.util.Locale.ROOT, "%.3f", seconds.asInstanceOf[AnyRef])
  def message: String = toString + "s"
}

class Timing(val elapsed: Time, val cpu: Time, val gc: Time)
{
  def message: String =
    elapsed.message + " elapsed time, " + cpu.message + " cpu time, " + gc.message + " GC time"
  override def toString = message
}