Created
October 2, 2025 10:38
-
-
Save mpickering/c0c280ea816e8b705795dd9a1a0b3cac to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env -S cabal run | |
| {- cabal: | |
| build-depends: base >=4.17 && <5 | |
| , directory >=1.3.8 | |
| , filepath >=1.4.100 | |
| , time | |
| , criterion >=1.6 | |
| default-language: GHC2021 | |
| ghc-options: -O2 | |
| -} | |
| -- Benchmark getModificationTime from System.Directory.OsPath | |
| -- | |
| -- Usage: | |
| -- ./mtime-bench.hs [PATH] | |
| -- PATH : file or directory to stat (default ".") | |
| -- | |
| -- Example: | |
| -- ./mtime-bench.hs /tmp | |
| import Criterion.Main | |
| import System.Environment (getArgs) | |
| import System.OsPath | |
| import System.Directory.OsPath (getModificationTime) | |
| main :: IO () | |
| main = do | |
| let path :: OsPath | |
| path = unsafeEncodeUtf "/home/matt/ghc-clean/cabal.project-reinstall" | |
| rel_path = unsafeEncodeUtf "cabal.project-reinstall" | |
| defaultMain | |
| [ | |
| bench ("getModificationTime " ++ show path) $ | |
| whnfIO (getModificationTime path) | |
| , bench ("getModificationTime " ++ show rel_path) $ | |
| whnfIO (getModificationTime rel_path) | |
| ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment