CurryInfo: benchmark-papers-3.0.0 / Test.Benchmark.benchCommand

definition:
benchCommand :: String -> Benchmark CmdResult
benchCommand cmd = benchmark $ do
  pid <- getPID
  let timefile = ".time" ++ show pid
      timecmd = "/usr/bin/time -q --format=\"BENCHMARKTIME=(%e,%U,%S,%M)\" -o "
                  ++ timefile ++ " " ++ cmd
  --putStrLn $ "TIMECMD: " ++ timecmd
  status <- system timecmd
  bmout <- readCompleteFile timefile
  case reads (extractTimeInOutput bmout) of
    [((etime,ctime,stime,maxmem),_)] -> do
      system $ "rm -f " ++ timefile
      --putStrLn $ "RESULT: " ++ show (CD cmd status etime ctime stime maxmem)
      return (CD cmd status etime ctime stime maxmem)
    _ -> error $ "Cannot read output of time command:\n" ++ bmout
 where
  -- extract benchmark time from timing output:
  extractTimeInOutput =
    tail . snd . break (=='=') . head . filter ("BENCHMARKTIME" `isPrefixOf`)
         . lines
demand:
no demanded arguments
deterministic:
deterministic operation
documentation:
--- Benchmark the execution of a shell command.
--- Returns benchmark results containing the exit status, elapsed time,
--- cpu time, system time, and the maximum resident size (in Kilobytes).
failfree:
<FAILING>
indeterministic:
referentially transparent operation
infix:
no fixity defined
iotype:
{(_) |-> _}
name:
benchCommand
precedence:
no precedence defined
result-values:
_
signature:
String -> Benchmark CmdResult
solution-complete:
operation might suspend on free variables
terminating:
possibly non-terminating
totally-defined:
possibly non-reducible on same data term