ghcide-bench 2.1.0.0 → 2.3.0.0
raw patch · 2 files changed
+47/−45 lines, 2 filesdep ~lsp-test
Dependency ranges changed: lsp-test
Files
- ghcide-bench.cabal +3/−3
- src/Experiments.hs +44/−42
ghcide-bench.cabal view
@@ -2,7 +2,7 @@ build-type: Simple category: Development name: ghcide-bench-version: 2.1.0.0+version: 2.3.0.0 license: Apache-2.0 license-file: LICENSE author: The Haskell IDE team@@ -12,7 +12,7 @@ description: An LSP client for running performance experiments on HLS homepage: https://github.com/haskell/haskell-language-server/tree/master/ghcide#readme bug-reports: https://github.com/haskell/haskell-language-server/issues-tested-with: GHC == 8.10.7 || == 9.0.2 || == 9.2.5+tested-with: GHC == 9.0.2 || == 9.2.5 source-repository head type: git@@ -119,7 +119,7 @@ base, extra, ghcide-bench,- lsp-test ^>= 0.15.0.1,+ lsp-test ^>= 0.16, tasty, tasty-hunit >= 0.10, tasty-rerun,
src/Experiments.hs view
@@ -29,7 +29,7 @@ import Control.Concurrent.Async (withAsync) import Control.Exception.Safe (IOException, handleAny, try)-import Control.Lens ((^.))+import Control.Lens (_Just, (&), (.~), (^.)) import Control.Lens.Extras (is) import Control.Monad.Extra (allM, forM, forM_, forever, unless, void, when,@@ -108,6 +108,22 @@ bench "hover" $ allWithIdentifierPos $ \DocumentPositions{..} -> isJust <$> getHover doc (fromJust identifierP), ---------------------------------------------------------------------------------------+ bench "hover after edit" $ \docs -> do+ forM_ docs $ \DocumentPositions{..} ->+ changeDoc doc [charEdit stringLiteralP]+ flip allWithIdentifierPos docs $ \DocumentPositions{..} ->+ isJust <$> getHover doc (fromJust identifierP),+ ---------------------------------------------------------------------------------------+ bench+ "hover after cradle edit"+ (\docs -> do+ hieYamlUri <- getDocUri "hie.yaml"+ liftIO $ appendFile (fromJust $ uriToFilePath hieYamlUri) "##\n"+ sendNotification SMethod_WorkspaceDidChangeWatchedFiles $ DidChangeWatchedFilesParams $+ [ FileEvent hieYamlUri FileChangeType_Changed ]+ flip allWithIdentifierPos docs $ \DocumentPositions{..} -> isJust <$> getHover doc (fromJust identifierP)+ ),+ --------------------------------------------------------------------------------------- bench "edit" $ \docs -> do forM_ docs $ \DocumentPositions{..} -> do changeDoc doc [charEdit stringLiteralP]@@ -128,12 +144,6 @@ waitForProgressDone return True, ---------------------------------------------------------------------------------------- bench "hover after edit" $ \docs -> do- forM_ docs $ \DocumentPositions{..} ->- changeDoc doc [charEdit stringLiteralP]- flip allWithIdentifierPos docs $ \DocumentPositions{..} ->- isJust <$> getHover doc (fromJust identifierP),- --------------------------------------------------------------------------------------- bench "getDefinition" $ allWithIdentifierPos $ \DocumentPositions{..} -> hasDefinitions <$> getDefinitions doc (fromJust identifierP), ---------------------------------------------------------------------------------------@@ -162,30 +172,21 @@ flip allWithIdentifierPos docs $ \DocumentPositions{..} -> not . null <$> getCompletions doc (fromJust identifierP), ---------------------------------------------------------------------------------------- benchWithSetup+ bench "code actions" ( \docs -> do unless (any (isJust . identifierP) docs) $ error "None of the example modules is suitable for this experiment"- forM_ docs $ \DocumentPositions{..} -> do- forM_ identifierP $ \p -> changeDoc doc [charEdit p]- waitForProgressStart- waitForProgressDone- )- ( \docs -> not . null . catMaybes <$> forM docs (\DocumentPositions{..} ->- forM identifierP $ \p ->- getCodeActions doc (Range p p))+ not . null . catMaybes <$> forM docs (\DocumentPositions{..} -> do+ forM identifierP $ \p ->+ getCodeActions doc (Range p p)) ), ---------------------------------------------------------------------------------------- benchWithSetup+ bench "code actions after edit" ( \docs -> do unless (any (isJust . identifierP) docs) $ error "None of the example modules is suitable for this experiment"- forM_ docs $ \DocumentPositions{..} ->- forM_ identifierP $ \p -> changeDoc doc [charEdit p]- )- ( \docs -> do forM_ docs $ \DocumentPositions{..} -> do changeDoc doc [charEdit stringLiteralP] waitForProgressStart@@ -195,16 +196,9 @@ getCodeActions doc (Range p p)) ), ---------------------------------------------------------------------------------------- benchWithSetup+ bench "code actions after cradle edit" ( \docs -> do- forM_ docs $ \DocumentPositions{..} -> do- forM identifierP $ \p -> do- changeDoc doc [charEdit p]- waitForProgressStart- void waitForBuildQueue- )- ( \docs -> do hieYamlUri <- getDocUri "hie.yaml" liftIO $ appendFile (fromJust $ uriToFilePath hieYamlUri) "##\n" sendNotification SMethod_WorkspaceDidChangeWatchedFiles $ DidChangeWatchedFilesParams $@@ -219,15 +213,22 @@ ), --------------------------------------------------------------------------------------- bench- "hover after cradle edit"- (\docs -> do- hieYamlUri <- getDocUri "hie.yaml"- liftIO $ appendFile (fromJust $ uriToFilePath hieYamlUri) "##\n"- sendNotification SMethod_WorkspaceDidChangeWatchedFiles $ DidChangeWatchedFilesParams $- [ FileEvent hieYamlUri FileChangeType_Changed ]- flip allWithIdentifierPos docs $ \DocumentPositions{..} -> isJust <$> getHover doc (fromJust identifierP)+ "code lens"+ ( \docs -> not . null <$> forM docs (\DocumentPositions{..} ->+ getCodeLenses doc) ), ---------------------------------------------------------------------------------------+ bench+ "code lens after edit"+ ( \docs -> do+ forM_ docs $ \DocumentPositions{..} -> do+ changeDoc doc [charEdit stringLiteralP]+ waitForProgressStart+ waitForProgressDone+ not . null <$> forM docs (\DocumentPositions{..} -> do+ getCodeLenses doc)+ ),+ --------------------------------------------------------------------------------------- benchWithSetup "hole fit suggestions" ( mapM_ $ \DocumentPositions{..} -> do@@ -363,8 +364,8 @@ createDirectoryIfMissing True eventlogDir lspConfig <- if Experiments.Types.lspConfig ?config- then either error Just . eitherDecodeStrict' <$> BS.getContents- else return Nothing+ then either error id . eitherDecodeStrict' <$> BS.getContents+ else return mempty let conf = defaultConfig { logStdErr = verbose ?config,@@ -483,7 +484,10 @@ ] ++ ["--ot-memory-profiling" | Just _ <- [otMemoryProfiling ?config]] lspTestCaps =- fullCaps {_window = Just $ WindowClientCapabilities (Just True) Nothing Nothing }+ fullCaps+ & (L.window . _Just) .~ WindowClientCapabilities (Just True) Nothing Nothing+ & (L.textDocument . _Just . L.codeAction . _Just . L.resolveSupport . _Just) .~ (#properties .== ["edit"])+ & (L.textDocument . _Just . L.codeAction . _Just . L.dataSupport . _Just) .~ True showMs :: Seconds -> String showMs = printf "%.2f"@@ -542,11 +546,9 @@ (Session BenchRun -> IO BenchRun) -> Bench -> IO BenchRun-runBench runSess b = handleAny (\e -> print e >> return badRun)+runBench runSess Bench{..} = handleAny (\e -> print e >> return badRun) $ runSess $ do- case b of- Bench{..} -> do (startup, docs) <- duration $ do (d, docs) <- duration $ setupDocumentContents ?config output $ "Setting up document contents took " <> showDuration d