1
1
mirror of https://github.com/anoma/juvix.git synced 2024-12-25 16:45:20 +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
putInfo ("Deleting " <> toFilePath resultsDir)
removePathForcibly resultsDir
phony "compile-only" (forM_ suites compileOnlyRules)
forM_ suites suiteRules
suiteRules :: Suite -> Rules ()
@ -31,12 +32,34 @@ suiteRules s = do
csvRules s
plotRules s
compileOnlyRules :: Suite -> Action ()
compileOnlyRules s = forM_ (s ^. suiteVariants) (variantBuildAction s)
multiRecipe :: [Path Abs File] -> Action () -> Rules ()
multiRecipe out howto = map toFilePath out &%> const howto
recipe :: Path Abs File -> Action () -> Rules ()
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 s v = do
action $ do

View File

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