Skip to content

Commit

Permalink
goblins-test: Print training duration
Browse files Browse the repository at this point in the history
  • Loading branch information
mhuesch committed Jul 16, 2019
1 parent 543bdcd commit 7c2f6b5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions byron/ledger/executable-spec/cs-ledger.cabal
Expand Up @@ -147,6 +147,7 @@ executable goblins-test
, tasty-hedgehog
, tasty-hunit
, text
, time
, tree-diff >=0.0.2
, typerep-map
default-language: Haskell2010
6 changes: 6 additions & 0 deletions byron/ledger/executable-spec/test/goblins-test/Main.hs
Expand Up @@ -8,6 +8,7 @@
import Control.Concurrent.Async (async, wait)
import Control.Monad (forM, forM_, replicateM_, unless)
import Data.List (partition)
import Data.Time.Clock (diffUTCTime, getCurrentTime)
import Data.TreeDiff.Class
import Data.TreeDiff.Expr
import qualified Data.TypeRepMap as TM
Expand Down Expand Up @@ -78,10 +79,15 @@ trainGoblins = do

let teeIt = tee (runDir </> "log" <.> "txt")
teeIt ("Run index: " <> show runIx)

startTime <- getCurrentTime
actions <- forM breeders $ \(PopStruct name action wrappedGenSigs) -> async $ do
pop <- action
pure (pop, name, wrappedGenSigs)
results <- traverse wait actions
endTime <- getCurrentTime
teeIt ("Training time was: " <> show (endTime `diffUTCTime` startTime))

let (good, bad) = partition (\(pop,_,_) -> (snd (head pop)) > 1.0) results
teeIt ("Total: " <> show (length results) <> ". Good: " <> show (length good) <> ". Bad: " <> show (length bad))
forM_ good $ \(pop, name, _) -> do
Expand Down

0 comments on commit 7c2f6b5

Please sign in to comment.