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.

Versions

  • plutus-tx: 1.40.0.0
  • plutarch: 1.10.1
  • aiken: v1.0.29-alpha+unknown
  • opshin: 0.24.0

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
Plutarch3363134151063
Aiken5596215601420
PlutusTx1691303920003019
Opshin1412261919624196

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
Plutarch1826273450394
Aiken2094072771222
PlutusTx66588364278572
Opshin39169515153098

Raw execution units data

LP Policy - mint two

execution_units plot

LanguageCPUMemory
Plutarch3182278583081
Aiken34254003115249
PlutusTx76849433325184
Opshin63319892234077

Raw execution units data

Pool NFT Policy - mint

execution_units plot

LanguageCPUMemory
Plutarch1599266841967
Aiken1882838057680
PlutusTx66772968281765
Opshin40795575174802

Raw execution units data

Pool Validator - swap A for B

execution_units plot

LanguageCPUMemory
Plutarch102778551233241
Aiken103843031320998
PlutusTx2927846371353180
Opshin252048642935119

Raw execution units data

Pool Validator - swap B for A

execution_units plot

LanguageCPUMemory
Plutarch102778551233241
Aiken103843031320998
PlutusTx2927846371353180
Opshin252048642935119

Raw execution units data

Pool Validator - deposit

execution_units plot

LanguageCPUMemory
Plutarch104183634234501
Aiken108022727335146
PlutusTx3282451881517862
Opshin257128376940115

Raw execution units data

Pool Validator - withdraw

execution_units plot

LanguageCPUMemory
Plutarch103879252233399
Aiken108343109336348
PlutusTx3286150231519364
Opshin257672758942717

Raw execution units data

NFT Marketplace - buy one

execution_units plot

LanguageCPUMemory
Plutarch1225666428669
Aiken1898913648289
PlutusTx127041829557062
Opshin45869696192397

Raw execution units data

NFT Marketplace - cancel one

execution_units plot

LanguageCPUMemory
Plutarch575695417509
Aiken1250211641565
PlutusTx80367926345018
Opshin31521405142689

Raw execution units data