)ab package TIMER NewTimingFunctions

NewTimingFunctions : PUB == PRIV where

  PUB == with
    totalTime : () -> Integer
      ++ Total counting time in milliseconds
    gcTime : () -> Integer
      ++ Gc counting time in milliseconds
    evaluationTime : () -> Integer
      ++ Evaluation counting time in milliseconds

  PRIV == add

    totalTime () ==
      evaluationTime() + gcTime()

    evaluationTime () ==
      (GET_-INTERNAL_-RUN_-TIME()$Lisp) pretend Integer

    gcTime () ==
       (GCTIME()$Lisp) pretend Integer


)ab package RUNF RunFunction

RunFunction(Dom:SetCategory) : PUB == PRIV where

  PUB == with

    runFunction : ((()->Dom),Dom) -> Integer
    doRun : ((()->Dom),Dom,String) -> Void
    mapRun : (List(()->Dom),Dom,String) -> Void

  PRIV == add

    mapRun(lf,res,mes) ==
      for f in lf repeat
        t := totalTime()$NewTimingFunctions
        runRes := f()
        (runRes = res) =>
          s : String := convert(totalTime()$NewTimingFunctions -t)$Integer
          messagePrint(concat([mes, " in ", s ]))$OutputForm
        messagePrint(concat(mes, " Bad result"))$OutputForm

    doRun(f,res,mes) ==
      t := totalTime()$NewTimingFunctions
      runRes := f()
      (runRes = res) =>
        s : String := convert(totalTime()$NewTimingFunctions -t)$Integer
        messagePrint(concat([mes, " in ", s ]))$OutputForm
      messagePrint(concat(mes, " Bad result"))$OutputForm

    runFunction(f,res) ==
      t := totalTime()$NewTimingFunctions
      runRes := f()
      if runRes = res
      then ( messagePrint("foo")$OutputForm ; totalTime()$NewTimingFunctions -t)
      else 0
