Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 83 additions & 0 deletions submissions/ecd/Scalus_1.4.0_nau/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# Benchmark Implementation Notes

**Scenario**: `ecd`

**Submission ID**: `Scalus_1.4.0_nau` (Format: `Language_Version_GitHubHandle`)

## Implementation Details

- **Compiler**: Scalus 1.4.0
- **Implementation Approach**: Direct @Compile of the prescribed naive recursive GCD.
- **Compilation Flags**: `Options.release`

## Performance Results

- See [metrics.json](metrics.json) for detailed performance measurements

## Algorithm Compliance

`EcdBase.scala` translates the prescribed algorithm one to one: the same base case, and the same
recursive calls with the same arguments. The Scalus compiler adds only general-purpose
optimizations, such as the recursion encoding and inlining.

```scala
package scalus.examples.cape.ecd

import scalus.compiler.Compile
import scalus.*
import scalus.uplc.builtin.Builtins.modInteger

/** CAPE `ecd` scenario: prescribed naive recursive Euclidean algorithm.
*
* Direct translation of the spec (fixed mode):
* {{{ecd a b | b == 0 = abs a | otherwise = ecd b (a `mod` b)}}}
*
* Haskell's `mod` takes the sign of the divisor, like the `modInteger` builtin. Scala's `%` is
* `rem`, which takes the sign of the dividend and changes the recursive arguments for negative
* inputs: `ecd(-12, 8)` must recurse into `ecd(8, 4)`, not `ecd(8, -4)`.
*/
@Compile
object EcdBase {
def ecd(a: BigInt, b: BigInt): BigInt =
if b == BigInt(0) then if a < 0 then -a else a
else ecd(b, modInteger(a, b))
}
```

## Reproducibility

### Source Code

- **Source Available**: true

#### For External Repository (recommended approach):

- **Direct Link**: [ecd](https://github.com/scalus3/scalus/tree/f1fa4a721ae7a97d78b57ce651550be0846a792e/scalus-examples/jvm/src/main/scala/scalus/examples/cape/ecd/)
- **Repository**: https://github.com/scalus3/scalus
- **Tag/Commit**: `f1fa4a721ae7a97d78b57ce651550be0846a792e`
- **Source Path**: `scalus-examples/jvm/src/main/scala/scalus/examples/cape/ecd/`

### Build Instructions

```sh
git clone https://github.com/scalus3/scalus
cd scalus
git checkout f1fa4a721ae7a97d78b57ce651550be0846a792e
nix develop # provides JDK 21 and sbt
sbt "scalusExamplesJVM/runMain scalus.examples.cape.GenerateSubmissions <path-to-UPLC-CAPE> 1.4.0"
```

This writes `submissions/<scenario>/Scalus_1.4.0_nau/` for all 8 scenarios: the `.uplc` file,
`metadata.json` and this README. Then run `treefmt` in the UPLC-CAPE checkout to apply the
`pretty-uplc` layout, which changes only whitespace. `scripts/cape-submit.sh` in the
Scalus repository runs all of this, then `cape submission verify` and `measure`.

### Compilation Configuration

- **Optimization Level**: release
- **Compilation Flags**: `Options.release`
- **Notable Configuration**: Targets Plutus V3, protocol version 11 (vanRossem), plutus-core 1.1.0. No traces.

## Notes

Compiled from Scala 3 with the Scalus compiler plugin, Options.release (PV11/vanRossem target: flexible case, batch-6 builtins), no traces. Direct translation of the prescribed Euclidean algorithm; the only compiler-automatic transforms are recursion encoding and inlining.
38 changes: 38 additions & 0 deletions submissions/ecd/Scalus_1.4.0_nau/ecd.uplc
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
(program
1.1.0
[
(lam
scalus_examples_cape_ecd_EcdBase__ecd'588-0
[
scalus_examples_cape_ecd_EcdBase__ecd'588-0
scalus_examples_cape_ecd_EcdBase__ecd'588-0
]
)
(lam
scalus_examples_cape_ecd_EcdBase__ecd'588-0
(lam
a_7714'589-1
(lam
b_7715'590-2
(case
[ [ (builtin equalsInteger) b_7715'590-2 ] (con integer 0) ]
(case
(constr
0
scalus_examples_cape_ecd_EcdBase__ecd'588-0
b_7715'590-2
[ [ (builtin modInteger) a_7714'589-1 ] b_7715'590-2 ]
)
scalus_examples_cape_ecd_EcdBase__ecd'588-0
)
(case
[ [ (builtin lessThanInteger) a_7714'589-1 ] (con integer 0) ]
a_7714'589-1
[ [ (builtin subtractInteger) (con integer 0) ] a_7714'589-1 ]
)
)
)
)
)
]
)
29 changes: 29 additions & 0 deletions submissions/ecd/Scalus_1.4.0_nau/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"compiler": {
"name": "Scalus",
"version": "1.4.0",
"commit_hash": "b836856a5b4e54cd40fe0aa5947922478e8f1237"
},
"compilation_config": {
"optimization_level": "release",
"target": "uplc",
"flags": [
"Options.release"
],
"min_protocol_version": 11
},
"contributors": [
{
"name": "Alexander Nemish",
"organization": "Lantr",
"contact": "@nau"
}
],
"submission": {
"date": "2026-10-28T19:41:17.001104Z",
"source_available": true,
"source_repository": "https://github.com/scalus3/scalus",
"source_commit_hash": "f1fa4a721ae7a97d78b57ce651550be0846a792e",
"implementation_notes": "Compiled from Scala 3 with the Scalus compiler plugin, Options.release (PV11/vanRossem target: flexible case, batch-6 builtins), no traces. Direct translation of the prescribed Euclidean algorithm; the only compiler-automatic transforms are recursion encoding and inlining."
}
}
159 changes: 159 additions & 0 deletions submissions/ecd/Scalus_1.4.0_nau/metrics.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
{
"evaluations": [
{
"cpu_units": 970397,
"description": "ECD of 0 and 12 should return 12 (edge case: first argument is zero)",
"execution_result": "success",
"included_in_aggregates": true,
"memory_units": 4404,
"name": "ecd_0_12"
},
{
"cpu_units": 497723,
"description": "ECD of 12 and 0 should return 12 (edge case: second argument is zero)",
"execution_result": "success",
"included_in_aggregates": true,
"memory_units": 2602,
"name": "ecd_12_0"
},
{
"cpu_units": 970397,
"description": "ECD of 7 and 7 should return 7 (edge case: identical numbers)",
"execution_result": "success",
"included_in_aggregates": true,
"memory_units": 4404,
"name": "ecd_7_7"
},
{
"cpu_units": 1915745,
"description": "ECD of 6 and 9 should return 3",
"execution_result": "success",
"included_in_aggregates": true,
"memory_units": 8008,
"name": "ecd_6_9"
},
{
"cpu_units": 1443071,
"description": "ECD of 12 and 8 should return 4",
"execution_result": "success",
"included_in_aggregates": true,
"memory_units": 6206,
"name": "ecd_12_8"
},
{
"cpu_units": 2388419,
"description": "ECD of 15 and 25 should return 5",
"execution_result": "success",
"included_in_aggregates": true,
"memory_units": 9810,
"name": "ecd_15_25"
},
{
"cpu_units": 2388419,
"description": "ECD of 17 and 19 should return 1 (coprime numbers)",
"execution_result": "success",
"included_in_aggregates": true,
"memory_units": 9810,
"name": "ecd_17_19"
},
{
"cpu_units": 2388419,
"description": "ECD of 13 and 29 should return 1 (coprime numbers)",
"execution_result": "success",
"included_in_aggregates": true,
"memory_units": 9810,
"name": "ecd_13_29"
},
{
"cpu_units": 1915745,
"description": "ECD of 48 and 18 should return 6",
"execution_result": "success",
"included_in_aggregates": true,
"memory_units": 8008,
"name": "ecd_48_18"
},
{
"cpu_units": 1443071,
"description": "ECD of 100 and 75 should return 25",
"execution_result": "success",
"included_in_aggregates": true,
"memory_units": 6206,
"name": "ecd_100_75"
},
{
"cpu_units": 1915745,
"description": "ECD of 1071 and 462 should return 21 (larger numbers)",
"execution_result": "success",
"included_in_aggregates": true,
"memory_units": 8008,
"name": "ecd_1071_462"
},
{
"cpu_units": 1443071,
"description": "ECD of 2520 and 1890 should return 630 (larger numbers)",
"execution_result": "success",
"included_in_aggregates": true,
"memory_units": 6206,
"name": "ecd_2520_1890"
},
{
"cpu_units": 1443071,
"description": "ECD of -12 and 8 should return 4 (negative first argument handled via abs)",
"execution_result": "success",
"included_in_aggregates": true,
"memory_units": 6206,
"name": "ecd_negative_12_8"
},
{
"cpu_units": 1608279,
"description": "ECD of 12 and -8 should return 4 (negative second argument handled via abs)",
"execution_result": "success",
"included_in_aggregates": true,
"memory_units": 6608,
"name": "ecd_12_negative_8"
}
],
"execution_environment": {
"evaluator": "PlutusTx.Eval-1.63.0.0"
},
"measurements": {
"block_cpu_budget_pct": 0.011942095,
"block_memory_budget_pct": 0.013625,
"cpu_units": {
"maximum": 2388419,
"median": 1525675,
"minimum": 497723,
"sum": 22731572
},
"excluded": {
"count": 0,
"cpu_units": {
"maximum": 0,
"sum": 0
},
"memory_units": {
"maximum": 0,
"sum": 0
}
},
"execution_fee_lovelace": 7196,
"memory_units": {
"maximum": 9810,
"median": 6407,
"minimum": 2602,
"sum": 96296
},
"reference_script_fee_lovelace": 690,
"script_size_bytes": 46,
"scripts_per_block": 7339,
"scripts_per_tx": 1681,
"term_size": 36,
"total_fee_lovelace": 7886,
"tx_cpu_budget_pct": 0.02388419,
"tx_memory_budget_pct": 0.05945454545454546
},
"scenario": "ecd",
"timestamp": "2026-10-28T19:42:07Z",
"version": "2.0.0",
"notes": "Generated using UPLC-CAPE measure tool"
}
53 changes: 53 additions & 0 deletions submissions/factorial/Scalus_1.4.0_nau/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Benchmark Implementation Notes

**Scenario**: `factorial`

**Submission ID**: `Scalus_1.4.0_nau` (Format: `Language_Version_GitHubHandle`)

## Implementation Details

- **Compiler**: Scalus 1.4.0
- **Implementation Approach**: Scala 3 @Compile function: the factorial recursion unrolled four times, computing every result at run time, correct for any integer input.
- **Compilation Flags**: `Options.release`

## Performance Results

- See [metrics.json](metrics.json) for detailed performance measurements

## Reproducibility

### Source Code

- **Source Available**: true

#### For External Repository (recommended approach):

- **Direct Link**: [factorial](https://github.com/scalus3/scalus/tree/9b26ab007d6b8790eb55da55cef3dd788c350a93/scalus-examples/jvm/src/main/scala/scalus/examples/cape/factorial/)
- **Repository**: https://github.com/scalus3/scalus
- **Tag/Commit**: `9b26ab007d6b8790eb55da55cef3dd788c350a93`
- **Source Path**: `scalus-examples/jvm/src/main/scala/scalus/examples/cape/factorial/`

### Build Instructions

```sh
git clone https://github.com/scalus3/scalus
cd scalus
git checkout 9b26ab007d6b8790eb55da55cef3dd788c350a93
nix develop # provides JDK 21 and sbt
sbt "scalusExamplesJVM/runMain scalus.examples.cape.GenerateSubmissions <path-to-UPLC-CAPE> 1.4.0"
```

This writes `submissions/<scenario>/Scalus_1.4.0_nau/` for all 8 scenarios: the `.uplc` file,
`metadata.json` and this README. Then run `treefmt` in the UPLC-CAPE checkout to apply the
`pretty-uplc` layout, which changes only whitespace. `scripts/cape-submit.sh` in the
Scalus repository runs all of this, then `cape submission verify` and `measure`.

### Compilation Configuration

- **Optimization Level**: release
- **Compilation Flags**: `Options.release`
- **Notable Configuration**: Targets Plutus V3, protocol version 11 (vanRossem), plutus-core 1.1.0. No traces.

## Notes

Compiled from Scala 3 (@Compile, Options.releaseUntagged). Computes every result at run time, with the recursion unrolled four times: factorial(n) = n(n-1)(n-2)(n-3) * factorial(n - 4) for n >= 4, n(n-1) for n = 2 and 3, and 1 for every n <= 1, negatives included. No values are precomputed. factorial(12) takes three recursive calls instead of eleven.
Loading
Loading