Skip to content

Commit 3773010

Browse files
authored
Benchmark improvements (#1178)
* [test-ci] fix wibble * [ghcide-bench] fix scrambled output * [ghcide-bench] add a new experiment: getDefinition after edit * [ghcide-bench] refine the position used for identifiers * [ghcide-bench] Support examples with multiple FOIs * [ghcide-bench] Allow identifierP to be optional * [ghcide-bench] experiments: do all edits first, then query * [ghcide-bench] Add examples with multiple FOIs * [ghcide-bench] add a completions (without edit) experiment * [ghcide-bench] Fix indentation * [ghcide-bench] Fix incomplete pattern match * [ghcide-bench] Include the documentContents setup in the "startup" metric * [ghcide-bench] fix wibble * [ghcide-bench] add more verbose output * [shake-bench] Consolidate -s code * [bench-hist] Fix: depend on # samples * [ghcide-bench] cache searchSymbol * [cabal-bench] --no-clean
1 parent 2ef6ff0 commit 3773010

File tree

7 files changed

+286
-173
lines changed

7 files changed

+286
-173
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ jobs:
4949
~/.cabal/store
5050
key: ${{ runner.os }}-${{ matrix.ghc }}-build-${{ hashFiles('cabal.project') }}
5151
restore-keys: |
52-
${{ runner.os }}-${{ matrix.ghc }}-bench-$${ hashFiles('cabal.project') }}
52+
${{ runner.os }}-${{ matrix.ghc }}-bench-${{ hashFiles('cabal.project') }}
5353
${{ runner.os }}-${{ matrix.ghc }}-build-
5454
${{ runner.os }}-${{ matrix.ghc }}
5555

ghcide/bench/config.yaml

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,23 @@ examples:
1414
# Medium-sized project without TH
1515
- name: Cabal
1616
version: 3.0.0.0
17-
module: Distribution/Simple.hs
17+
modules:
18+
- Distribution/Simple.hs
19+
- Distribution/Types/Module.hs
1820
# Small-sized project with TH
19-
- name: haskell-lsp-types
20-
version: 0.22.0.0
21-
module: src/Language/Haskell/LSP/Types/Lens.hs
22-
# - path: path-to-example
23-
# module: path-to-module
21+
- name: lsp-types
22+
version: 1.0.0.1
23+
modules:
24+
- src/Language/LSP/VFS.hs
25+
- src/Language/LSP/Types/Lens.hs
2426

2527
# The set of experiments to execute
2628
experiments:
27-
- hover
28-
- edit
29-
- getDefinition
29+
- "edit"
30+
- "hover"
3031
- "hover after edit"
32+
- "getDefinition"
33+
- "getDefinition after edit"
3134
- "completions after edit"
3235
- "code actions"
3336
- "code actions after edit"

ghcide/bench/exe/Main.hs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,23 @@
3737
import Control.Exception.Safe
3838
import Experiments
3939
import Options.Applicative
40+
import System.IO
41+
import Control.Monad
42+
43+
optsP :: Parser (Config, Bool)
44+
optsP = (,) <$> configP <*> switch (long "no-clean")
4045

4146
main :: IO ()
4247
main = do
43-
config <- execParser $ info (configP <**> helper) fullDesc
48+
hSetBuffering stdout LineBuffering
49+
hSetBuffering stderr LineBuffering
50+
(config, noClean) <- execParser $ info (optsP <**> helper) fullDesc
4451
let ?config = config
4552

53+
hPrint stderr config
54+
4655
output "starting test"
4756

4857
SetupResult{..} <- setup
4958

50-
runBenchmarks experiments `finally` cleanUp
59+
runBenchmarks experiments `finally` unless noClean cleanUp

ghcide/bench/hist/Main.hs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ import Experiments.Types (Example, exampleToOptions)
5151
import qualified Experiments.Types as E
5252
import GHC.Generics (Generic)
5353
import Numeric.Natural (Natural)
54+
import Development.Shake.Classes
5455

5556

5657
config :: FilePath
@@ -70,7 +71,7 @@ main = shakeArgs shakeOptions {shakeChange = ChangeModtimeAndDigest} $ do
7071
configStatic <- liftIO $ readConfigIO config
7172
let build = outputFolder configStatic
7273
buildRules build ghcideBuildRules
73-
benchRules build resource (MkBenchRules (benchGhcide $ samples configStatic) "ghcide")
74+
benchRules build resource (MkBenchRules (askOracle $ GetSamples ()) benchGhcide "ghcide")
7475
csvRules build
7576
svgRules build
7677
action $ allTargets build
@@ -98,14 +99,18 @@ createBuildSystem userRules = do
9899

99100
_ <- addOracle $ \GetExperiments {} -> experiments <$> readConfig config
100101
_ <- addOracle $ \GetVersions {} -> versions <$> readConfig config
101-
_ <- addOracle $ \GetExamples{} -> examples <$> readConfig config
102-
_ <- addOracle $ \(GetExample name) -> find (\e -> getExampleName e == name) . examples <$> readConfig config
102+
_ <- versioned 1 $ addOracle $ \GetExamples{} -> examples <$> readConfig config
103+
_ <- versioned 1 $ addOracle $ \(GetExample name) -> find (\e -> getExampleName e == name) . examples <$> readConfig config
103104
_ <- addOracle $ \GetBuildSystem {} -> buildTool <$> readConfig config
105+
_ <- addOracle $ \GetSamples{} -> samples <$> readConfig config
104106

105107
benchResource <- newResource "ghcide-bench" 1
106108

107109
userRules benchResource
108110

111+
newtype GetSamples = GetSamples () deriving newtype (Binary, Eq, Hashable, NFData, Show)
112+
type instance RuleResult GetSamples = Natural
113+
109114
--------------------------------------------------------------------------------
110115

111116
buildGhcide :: BuildSystem -> [CmdOption] -> FilePath -> Action ()
@@ -130,9 +135,10 @@ buildGhcide Stack args out =
130135

131136
benchGhcide
132137
:: Natural -> BuildSystem -> [CmdOption] -> BenchProject Example -> Action ()
133-
benchGhcide samples buildSystem args BenchProject{..} =
138+
benchGhcide samples buildSystem args BenchProject{..} = do
134139
command_ args "ghcide-bench" $
135140
[ "--timeout=3000",
141+
"--no-clean",
136142
"-v",
137143
"--samples=" <> show samples,
138144
"--csv=" <> outcsv,

0 commit comments

Comments
 (0)