-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget.txt
45 lines (41 loc) · 1.37 KB
/
get.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
bench_get = do
system "make paper.hs >&2"
system $ "rm -rf " ++ dir
system $ "mkdir " ++ dir
-- precompile dependencies
forM_ ghcs $ \ghc -> do
call ghc "paper.hs"
-- headers
putStr "iterations"
forM_ ghcs $ \ghc -> forM_ records $ \record ->
putStr $ ", " ++ ghc ++ " " ++ name record
putChar '\n'
-- body
forM_ iters $ \iter -> do
putStr $ show iter ++ ", "
forM_ ghcs $ \ghc -> forM_ records $ \record -> do
let run = dir ++ "get_" ++ show iter ++ "_" ++ ghc ++ "_" ++ name record ++ ".hs"
writeFile run $ "\
\{-# LANGUAGE NoMonomorphismRestriction #-}\n\
\import Paper\n\
\\n\
\main = go (99999::Int) where\n\
\ go i = if i == 0 then return() else go (i - get (make i) L2)\n\
\\n\
\{-# NOINLINE make #-}\n\
\make i = list\n\
\\n\
\list =\n" ++
concat (replicate iter " cons (L1 .=. (0::Int)) $\n") ++
" cons (L2 .=. (1::Int)) nil" ++
"\ncons = " ++ cons record ++
"\nnil = " ++ nil record ++
"\nget = " ++ get record ++ "\n"
system $ "rm " ++ dir ++ ghc ++ "_dir/Main.*" -- workaround http://hackage.haskell.org/trac/ghc/ticket/7038
call ghc run
start <- getCurrentTime
system $ dir ++ "get_" ++ show iter ++ "_" ++ ghc ++ "_" ++ name record
end <- getCurrentTime
putStr $ show (end `diffUTCTime` start) ++ ", "
hFlush stdout
putChar '\n'