1
1
mirror of https://github.com/anoma/juvix.git synced 2024-12-26 09:04:18 +03:00

Fix benchmarks suite juvix compile variants (#2717)

The `--target` flag was replaced by subcommands in
https://github.com/anoma/juvix/pull/2700

This PR fixes the benchmark suite to use `juvix compile native` and
`juvix compile wasi`.

In addition this PR adds as `compile-only` target to `juvix-bench`

The compile-only target only compiles the executable for each variant of
each suite. It doesn't actually run the benchmarks. This is useful when
checking that the variant build steps are correct before committing.

Example to run with stack:

```
stack bench --ba 'compile-only'
```
This commit is contained in:
Paul Cadman 2024-04-10 17:54:03 +01:00 committed by GitHub
parent af2a8d4715
commit 1fd3b3437a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 25 additions and 2 deletions

View File

@ -23,6 +23,7 @@ compileRules = do
phony "clean" $ do phony "clean" $ do
putInfo ("Deleting " <> toFilePath resultsDir) putInfo ("Deleting " <> toFilePath resultsDir)
removePathForcibly resultsDir removePathForcibly resultsDir
phony "compile-only" (forM_ suites compileOnlyRules)
forM_ suites suiteRules forM_ suites suiteRules
suiteRules :: Suite -> Rules () suiteRules :: Suite -> Rules ()
@ -31,12 +32,34 @@ suiteRules s = do
csvRules s csvRules s
plotRules s plotRules s
compileOnlyRules :: Suite -> Action ()
compileOnlyRules s = forM_ (s ^. suiteVariants) (variantBuildAction s)
multiRecipe :: [Path Abs File] -> Action () -> Rules () multiRecipe :: [Path Abs File] -> Action () -> Rules ()
multiRecipe out howto = map toFilePath out &%> const howto multiRecipe out howto = map toFilePath out &%> const howto
recipe :: Path Abs File -> Action () -> Rules () recipe :: Path Abs File -> Action () -> Rules ()
recipe out howto = toFilePath out %> const howto recipe out howto = toFilePath out %> const howto
variantBuildAction :: Suite -> Variant -> Action ()
variantBuildAction s v = (v ^. variantBuild) args
where
args :: BuildArgs
args =
BuildArgs
{ _buildSrc = srcFile,
_buildOutDir = outDir
}
lang :: Lang
lang = v ^. variantLanguage
srcFile :: Path Abs File
srcFile =
addExtension'
(langExtension lang)
(suiteSrcDir s <//> langPath lang <//> suiteBaseFile s)
outDir :: Path Abs Dir
outDir = variantBinDir s v
variantRules :: Suite -> Variant -> Rules () variantRules :: Suite -> Variant -> Rules ()
variantRules s v = do variantRules s v = do
action $ do action $ do

View File

@ -147,7 +147,7 @@ juvixExe =
_variantColor = getVariantColor JuvixExe, _variantColor = getVariantColor JuvixExe,
_variantRun = runExe, _variantRun = runExe,
_variantBuild = \args -> _variantBuild = \args ->
command_ [] "juvix" (juvixCommon ++ commonOptions args ext) command_ [] "juvix" (juvixCommon ++ ["native"] ++ commonOptions args ext)
} }
where where
ext :: [String] ext :: [String]
@ -165,7 +165,7 @@ juvixWasm =
_variantColor = getVariantColor JuvixWasm, _variantColor = getVariantColor JuvixWasm,
_variantRun = runWasm, _variantRun = runWasm,
_variantBuild = \args -> _variantBuild = \args ->
command_ [] "juvix" (juvixCommon ++ ["--target=wasm32-wasi"] ++ commonOptions args ext) command_ [] "juvix" (juvixCommon ++ ["wasi"] ++ commonOptions args ext)
} }
where where
ext :: [String] ext :: [String]