Introduction

Cardano smart-contract language ecosystem develops rapidly and offers many languages without a single and comprehensive performance comparison. The purpose of Cardano onchain language benchmark project is to implement the same suite of Cardano onchain validators in multiple languages compiled to UPLC, develop a language-agnostic test suite to test the equivalence of validators, and measure the performance of each language looking at script size and execution units.

Specifications of validators that are to be implemented in each language are available here.

Benchmark results, when available, will be published on this website.

Everything, including specifications and this website is open-source and available on GitHub.

Specifications

Comparison

While trying to implement all validators as closely to each other as possible there are some differences that impact measured script size and execution units.

  • Plutarch while decoding Data-encoded types is checking for invariants such as hashes lengths, map key ordering etc. which leads to higher start up cost visible in NFT Marketplace validator.
  • Opshin does expose option to compile without tracing so that is included in the final size. All implementations use traces in their source code but remaining allow to strip it with a compilation flag.
  • Note that opshin validators are not benchmarked currently as they do not support PlutusV3 yet. They will be restored when they will support it. We have decided to migrate to V3 as Aiken cannot target older Plutus versions.

Versions

  • plutus-tx: 1.40.0.0
  • plutarch: 1.10.1
  • aiken: v1.1.16+unknown
  • opshin: 0.24.1

Script size (bytes)

Script sizes are compared by compiling each script to CBOR and taking its binary size in bytes. Validators are compiled without traces if language supports it (Opshin does not) and are not passed through any external UPLC optimizer.

size plot

Languagelp-minting-policy.binnft-marketplace-validator.binnft-minting-policy.binpool-validator.bin
Plutarch3203504061081
Aiken4853863991502
PlutusTx2938433332044330

Raw script size data

Execution Units

Execution units are abstract units of CEK machine. Despite being called CPU and Memory they DO NOT mean CPU cycles or allocated bytes, these are abstract, deterministic units of the virtual machine that executes UPLC.

LP Policy - mint one

execution_units plot

LanguageCPUMemory
Plutarch1779766147962
Aiken1736631456974
PlutusTx65739767276544

Raw execution units data

LP Policy - mint two

execution_units plot

LanguageCPUMemory
Plutarch3101897679485
Aiken2893633894149
PlutusTx76000836323156

Raw execution units data

Pool NFT Policy - mint

execution_units plot

LanguageCPUMemory
Plutarch1529944140575
Aiken1492380238363
PlutusTx63511332269611

Raw execution units data

Pool Validator - swap A for B

execution_units plot

LanguageCPUMemory
Plutarch101745804230523
Aiken79768207234780
PlutusTx2968272681371798

Raw execution units data

Pool Validator - swap B for A

execution_units plot

LanguageCPUMemory
Plutarch101745804230523
Aiken79768207234780
PlutusTx2968272681371798

Raw execution units data

Pool Validator - deposit

execution_units plot

LanguageCPUMemory
Plutarch102846505230681
Aiken81975434241842
PlutusTx3285697861521400

Raw execution units data

Pool Validator - withdraw

execution_units plot

LanguageCPUMemory
Plutarch103150887231783
Aiken82279816242944
PlutusTx3289396211522902

Raw execution units data

NFT Marketplace - buy one

execution_units plot

LanguageCPUMemory
Plutarch1352518132227
Aiken1338976828583
PlutusTx3349481111379416

Raw execution units data

NFT Marketplace - cancel one

execution_units plot

LanguageCPUMemory
Plutarch821625724229
Aiken714251922591
PlutusTx138764847579120

Raw execution units data