summaryrefslogtreecommitdiff
path: root/benchmarks/hs/gen-program.hs
diff options
context:
space:
mode:
Diffstat (limited to 'benchmarks/hs/gen-program.hs')
-rw-r--r--benchmarks/hs/gen-program.hs20
1 files changed, 20 insertions, 0 deletions
diff --git a/benchmarks/hs/gen-program.hs b/benchmarks/hs/gen-program.hs
new file mode 100644
index 0000000..1ecc84d
--- /dev/null
+++ b/benchmarks/hs/gen-program.hs
@@ -0,0 +1,20 @@
+import qualified Data.Graph.Dynamic.Program as Program
+import qualified Data.Text.Lazy.IO as TL
+import System.Environment (getArgs, getProgName)
+import System.Exit (exitFailure)
+import qualified System.IO as IO
+import qualified Test.QuickCheck as QC
+import Text.Read (readMaybe)
+
+main :: IO ()
+main = do
+ progName <- getProgName
+ args <- getArgs
+ case args of
+ [sizeStr] | Just size <- readMaybe sizeStr -> do
+ Program.IntGraphProgram sample <- head <$>
+ QC.sample' (QC.resize size QC.arbitrary)
+ TL.putStrLn $ Program.encodeProgram Program.encodeInt sample
+ _ -> do
+ IO.hPutStrLn IO.stderr $ "Usage: " ++ progName ++ " size"
+ exitFailure