Skip to content

Commit 3b2a0fd

Browse files
authored
Merge pull request #646 from avh4/perf-tests
Add profiling script and merge #643
2 parents 1fa616f + f796392 commit 3b2a0fd

File tree

4 files changed

+43
-2
lines changed

4 files changed

+43
-2
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@
88
/.shake/
99
/_build/
1010
/generated/
11+
/_profile/

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## master
2+
3+
Bug fixes:
4+
- performance is improved, allowing excessively long lists to be formatted without crashing
5+
6+
17
## 0.8.2
28

39
New features:

Shakefile.hs

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ main = do
1414
} $ do
1515
StdoutTrim stackLocalInstallRoot <- liftIO $ cmd "stack path --local-install-root"
1616
StdoutTrim stackLocalBin <- liftIO $ cmd "stack path --local-bin"
17+
StdoutTrim gitDescribe <- liftIO $ cmd "git" [ "describe", "--abbrev=8", "--always" ]
18+
StdoutTrim gitSha <- liftIO $ cmd "git" [ "describe", "--always", "--match", "NOT A TAG", "--dirty" ]
1719

1820
let elmFormat = stackLocalInstallRoot </> "bin/elm-format" <.> exe
1921
let shellcheck = stackLocalBin </> "shellcheck" <.> exe
@@ -29,6 +31,7 @@ main = do
2931

3032
phony "build" $ need [ elmFormat ]
3133
phony "stack-test" $ need [ "_build/stack-test.ok" ]
34+
phony "profile" $ need [ "_build/tests/test-files/prof.ok" ]
3235

3336
phony "clean" $ do
3437
cmd_ "stack clean"
@@ -56,7 +59,6 @@ main = do
5659

5760
"generated/Build_elm_format.hs" %> \out -> do
5861
alwaysRerun
59-
(StdoutTrim gitDescribe) <- cmd "git" [ "describe", "--abbrev=8", "--always" ]
6062
writeFileChanged out $ unlines
6163
[ "module Build_elm_format where"
6264
, ""
@@ -70,6 +72,15 @@ main = do
7072
need generatedSourceFiles
7173
cmd_ "stack build --test --no-run-tests"
7274

75+
"_build/bin/elm-format-prof" %> \out -> do
76+
StdoutTrim profileInstallRoot <- liftIO $ cmd "stack path --profile --local-install-root"
77+
sourceFiles <- getDirectoryFiles "" sourceFilesPattern
78+
need sourceFiles
79+
need generatedSourceFiles
80+
cmd_ "stack build --profile --executable-profiling --library-profiling"
81+
copyFileChanged (profileInstallRoot </> "bin/elm-format" <.> exe) out
82+
83+
7384
--
7485
-- Haskell tests
7586
--
@@ -124,6 +135,15 @@ main = do
124135
cmd_ ("bash" <.> exe) script elmFormat
125136
writeFile' out ""
126137

138+
"_build/tests/test-files/prof.ok" %> \out -> do
139+
let oks =
140+
[ "_build/tests/test-files/good/Elm-0.17/prof.ok"
141+
, "_build/tests/test-files/good/Elm-0.18/prof.ok"
142+
, "_build/tests/test-files/good/Elm-0.19/prof.ok"
143+
]
144+
need oks
145+
writeFile' out (unlines oks)
146+
127147

128148
-- Elm files
129149

@@ -138,6 +158,20 @@ main = do
138158
need oks
139159
writeFile' out (unlines elmFiles)
140160

161+
("_build/tests/test-files/good/Elm-" ++ elmVersion ++ "/prof.ok") %> \out -> do
162+
alwaysRerun
163+
elmFiles <- getDirectoryFiles ""
164+
[ "tests/test-files/good/Elm-" ++ elmVersion ++ "//*.elm"
165+
]
166+
let oks = ["_profile" </> f -<.> (gitSha ++ ".prof") | f <- elmFiles]
167+
need oks
168+
writeFile' out (unlines oks)
169+
170+
("_profile/tests/test-files/good/Elm-" ++ elmVersion ++ "//*." ++ gitSha ++ ".prof") %> \out -> do
171+
let source = dropDirectory1 $ dropExtensions out <.> "elm"
172+
need [ "_build/bin/elm-format-prof", source ]
173+
cmd_ "_build/bin/elm-format-prof" source "--output" "/dev/null" ("--elm-version=" ++ elmVersion) "+RTS" "-p" ("-po" ++ (out -<.> ""))
174+
141175
("_build/tests/test-files/*/Elm-" ++ elmVersion ++ "//*.elm_formatted") %> \out -> do
142176
let source = dropDirectory1 $ out -<.> "elm"
143177
need [ elmFormat, source ]

src/Box.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ stack1 children =
119119
[first] ->
120120
first
121121
boxes ->
122-
foldl1 stack' boxes
122+
foldr1 stack' boxes
123123

124124

125125
mapLines :: (Line -> Line) -> Box -> Box

0 commit comments

Comments
 (0)