Skip to content

Commit

Permalink
Merge pull request avh4#646 from avh4/perf-tests
Browse files Browse the repository at this point in the history
Add profiling script and merge avh4#643
  • Loading branch information
avh4 authored Nov 15, 2019
2 parents 38681fc + 0f0b194 commit a4582c2
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@
/.shake/
/_build/
/generated/
/_profile/
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## master

Bug fixes:
- performance is improved, allowing excessively long lists to be formatted without crashing


## 0.8.2

New features:
Expand Down
36 changes: 35 additions & 1 deletion Shakefile.hs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ main = do
} $ do
StdoutTrim stackLocalInstallRoot <- liftIO $ cmd "stack path --local-install-root"
StdoutTrim stackLocalBin <- liftIO $ cmd "stack path --local-bin"
StdoutTrim gitDescribe <- liftIO $ cmd "git" [ "describe", "--abbrev=8", "--always" ]
StdoutTrim gitSha <- liftIO $ cmd "git" [ "describe", "--always", "--match", "NOT A TAG", "--dirty" ]

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

phony "build" $ need [ elmFormat ]
phony "stack-test" $ need [ "_build/stack-test.ok" ]
phony "profile" $ need [ "_build/tests/test-files/prof.ok" ]

phony "clean" $ do
cmd_ "stack clean"
Expand Down Expand Up @@ -56,7 +59,6 @@ main = do

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

"_build/bin/elm-format-prof" %> \out -> do
StdoutTrim profileInstallRoot <- liftIO $ cmd "stack path --profile --local-install-root"
sourceFiles <- getDirectoryFiles "" sourceFilesPattern
need sourceFiles
need generatedSourceFiles
cmd_ "stack build --profile --executable-profiling --library-profiling"
copyFileChanged (profileInstallRoot </> "bin/elm-format" <.> exe) out


--
-- Haskell tests
--
Expand Down Expand Up @@ -124,6 +135,15 @@ main = do
cmd_ ("bash" <.> exe) script elmFormat
writeFile' out ""

"_build/tests/test-files/prof.ok" %> \out -> do
let oks =
[ "_build/tests/test-files/good/Elm-0.17/prof.ok"
, "_build/tests/test-files/good/Elm-0.18/prof.ok"
, "_build/tests/test-files/good/Elm-0.19/prof.ok"
]
need oks
writeFile' out (unlines oks)


-- Elm files

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

("_build/tests/test-files/good/Elm-" ++ elmVersion ++ "/prof.ok") %> \out -> do
alwaysRerun
elmFiles <- getDirectoryFiles ""
[ "tests/test-files/good/Elm-" ++ elmVersion ++ "//*.elm"
]
let oks = ["_profile" </> f -<.> (gitSha ++ ".prof") | f <- elmFiles]
need oks
writeFile' out (unlines oks)

("_profile/tests/test-files/good/Elm-" ++ elmVersion ++ "//*." ++ gitSha ++ ".prof") %> \out -> do
let source = dropDirectory1 $ dropExtensions out <.> "elm"
need [ "_build/bin/elm-format-prof", source ]
cmd_ "_build/bin/elm-format-prof" source "--output" "/dev/null" ("--elm-version=" ++ elmVersion) "+RTS" "-p" ("-po" ++ (out -<.> ""))

("_build/tests/test-files/*/Elm-" ++ elmVersion ++ "//*.elm_formatted") %> \out -> do
let source = dropDirectory1 $ out -<.> "elm"
need [ elmFormat, source ]
Expand Down
2 changes: 1 addition & 1 deletion src/Box.hs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ stack1 children =
[first] ->
first
boxes ->
foldl1 stack' boxes
foldr1 stack' boxes


mapLines :: (Line -> Line) -> Box -> Box
Expand Down

0 comments on commit a4582c2

Please sign in to comment.