summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Cady <d@jerkface.net>2015-12-03 23:21:26 -0500
committerAndrew Cady <d@jerkface.net>2015-12-03 23:21:26 -0500
commitf10b0fff42f936fe35adf21306495077b43356a7 (patch)
tree385f435a7c4af2e94a2023d70e9f9e1def735c7a
parent15af2a70a9dec1d7b72f58e39832b8d6ba276c80 (diff)
changing the ghc options fixed the performance issue (-O2 and/or -threaded)
-rw-r--r--axis-of-eval.cabal1
-rw-r--r--midi-dump.hs10
2 files changed, 8 insertions, 3 deletions
diff --git a/axis-of-eval.cabal b/axis-of-eval.cabal
index 73ba50f..f69d3f5 100644
--- a/axis-of-eval.cabal
+++ b/axis-of-eval.cabal
@@ -29,3 +29,4 @@ executable midi-dump
29 base, time, containers, haskore, alsa-seq, alsa-core, mtl, clock, sqlite-simple, bytestring, base-prelude 29 base, time, containers, haskore, alsa-seq, alsa-core, mtl, clock, sqlite-simple, bytestring, base-prelude
30 main-is: midi-dump.hs 30 main-is: midi-dump.hs
31 other-modules: AlsaSeq 31 other-modules: AlsaSeq
32 ghc-options: -threaded -W -Wall -O2
diff --git a/midi-dump.hs b/midi-dump.hs
index ad9fd46..b9911c8 100644
--- a/midi-dump.hs
+++ b/midi-dump.hs
@@ -60,7 +60,8 @@ data LoopEnv = LoopEnv {
60 private :: Sound.ALSA.Sequencer.Port.T, 60 private :: Sound.ALSA.Sequencer.Port.T,
61 q :: Sound.ALSA.Sequencer.Queue.T, 61 q :: Sound.ALSA.Sequencer.Queue.T,
62 publicAddr :: Sound.ALSA.Sequencer.Address.T, 62 publicAddr :: Sound.ALSA.Sequencer.Address.T,
63 privateAddr :: Sound.ALSA.Sequencer.Address.T 63 privateAddr :: Sound.ALSA.Sequencer.Address.T,
64 doSave :: Bool
64} 65}
65 66
66getAbsTime = do 67getAbsTime = do
@@ -83,7 +84,9 @@ main' = withAlsaInit $ \h public private q publicAddr privateAddr -> do
83 execute_ sqlite "CREATE TABLE IF NOT EXISTS chunks (id INTEGER PRIMARY KEY, sec INTEGER, nsec INTEGER, midi BLOB)" 84 execute_ sqlite "CREATE TABLE IF NOT EXISTS chunks (id INTEGER PRIMARY KEY, sec INTEGER, nsec INTEGER, midi BLOB)"
84 saver <- startSaver sqlite 85 saver <- startSaver sqlite
85 86
86 let env = LoopEnv saver sqlite startTime startTimeReal h public private q publicAddr privateAddr 87 doSave <- isJust <$> lookupEnv "SAVE_MIDI"
88
89 let env = LoopEnv saver sqlite startTime startTimeReal h public private q publicAddr privateAddr doSave
87 90
88 (_, ()) <- execRWST loop env (emptyLoopState startTime) 91 (_, ()) <- execRWST loop env (emptyLoopState startTime)
89 return () 92 return ()
@@ -119,7 +122,8 @@ loop = do
119 modify $ \s -> s { inputHistory = Silence now:inputHistory s } 122 modify $ \s -> s { inputHistory = Silence now:inputHistory s }
120 -} 123 -}
121 124
122 gets inputHistory >>= saveMidi >> return () 125 doSave <- asks doSave
126 when doSave $ gets inputHistory >>= saveMidi >> return ()
123 modify $ \s -> s { inputHistory = [] } 127 modify $ \s -> s { inputHistory = [] }
124 128
125 loop 129 loop