waves_logo Docs
  • Ride Programming Language
    Ride Programming Language
  • Getting Started
    Getting Started
  • Syntax Basics
    • Directives
      Directives
    • Definition
      Definition
    • Expression
      Expression
    • Constant
      Constant
    • Variable
      Variable
    • Function
      Function
    • Exception
      Exception
    • Comment
      Comment
    Syntax Basics
  • Script Types
    • dApp Script
      • Annotations
        Annotations
      • Callable Function
        Callable Function
      • Verifier Function
        Verifier Function
      dApp Script
    • Account Script
      Account Script
    • Asset Script
      Asset Script
    Script Types
  • Standard Library
    Standard Library
  • Data types
    • Boolean
      Boolean
    • ByteVector
      ByteVector
    • Int
      Int
    • String
      String
    • Unit
      Unit
    • List
      List
    • Tuple
      Tuple
    • Union
      Union
    Data types
  • Structures
    • Script Actions
      • BinaryEntry (v4)
        BinaryEntry (v4)
      • BooleanEntry (v4)
        BooleanEntry (v4)
      • Burn (v4)
        Burn (v4)
      • DataEntry (v3)
        DataEntry (v3)
      • DeleteEntry (v4)
        DeleteEntry (v4)
      • IntegerEntry (v4)
        IntegerEntry (v4)
      • Issue (v4)
        Issue (v4)
      • Reissue (v4)
        Reissue (v4)
      • ScriptTransfer (v3 and v4)
        ScriptTransfer (v3 and v4)
      • SponsorFee (v4)
        SponsorFee (v4)
      • StringEntry (v4)
        StringEntry (v4)
      Script Actions
    • Script Results (v3)
      • ScriptResult
        ScriptResult
      • TransferSet
        TransferSet
      • WriteSet
        WriteSet
      Script Results (v3)
    • Common Structures
      • Address
        Address
      • Alias
        Alias
      • Asset
        Asset
      • AssetPair
        AssetPair
      • AttachedPayment
        AttachedPayment
      • BalanceDetails
        BalanceDetails
      • BlockInfo
        BlockInfo
      • Invocation
        Invocation
      • Order
        Order
      • Transfer
        Transfer
      Common Structures
    • Transaction Structures
      • BurnTransaction
        BurnTransaction
      • CreateAliasTransaction
        CreateAliasTransaction
      • DataTransaction
        DataTransaction
      • ExchangeTransaction
        ExchangeTransaction
      • GenesisTransaction
        GenesisTransaction
      • InvokeScriptTransaction
        InvokeScriptTransaction
      • IssueTransaction
        IssueTransaction
      • LeaseCancelTransaction
        LeaseCancelTransaction
      • LeaseTransaction
        LeaseTransaction
      • MassTransferTransaction
        MassTransferTransaction
      • ReissueTransaction
        ReissueTransaction
      • SetAssetScriptTransaction
        SetAssetScriptTransaction
      • SetScriptTransaction
        SetScriptTransaction
      • SponsorFeeTransaction
        SponsorFeeTransaction
      • TransferTransaction
        TransferTransaction
      • UpdateAssetInfoTransaction
        UpdateAssetInfoTransaction
      Transaction Structures
    Structures
  • Built-in Variables
    Built-in Variables
  • Built-in Functions
    • Account Data Storage Functions
      Account Data Storage Functions
    • Blockchain Functions
      Blockchain Functions
    • Byte Array Functions
      Byte Array Functions
    • Converting Functions
      Converting Functions
    • Data Transaction Functions
      Data Transaction Functions
    • Decoding Functions
      Decoding Functions
    • Encoding Functions
      Encoding Functions
    • Exception Functions
      Exception Functions
    • Hashing Functions
      Hashing Functions
    • List Functions
      List Functions
    • Math Functions
      Math Functions
    • String Functions
      String Functions
    • Union Functions
      Union Functions
    • Verification Functions
      Verification Functions
    Built-in Functions
  • Operators
    Operators
  • Pattern Matching: match-case
    Pattern Matching: match-case
  • Interations with FOLD<N>
    Interations with FOLD<N>
  • Limitations
    • Complexity
      Complexity
    • Data Weight
      Data Weight
    Limitations
  • Version 5 (Stagenet)
    • dApp-to-dApp Invocation
      dApp-to-dApp Invocation
    • Strict Variable
      Strict Variable
    • Callable Function
      Callable Function
    • Data types
      • Any
        Any
      • BigInt
        BigInt
      • Boolean
        Boolean
      • ByteVector
        ByteVector
      • Int
        Int
      • String
        String
      • Unit
        Unit
      • List
        List
      • Tuple
        Tuple
      • Union
        Union
      Data types
    • Structures
      • Script Actions
        • BinaryEntry
          BinaryEntry
        • BooleanEntry
          BooleanEntry
        • Burn
          Burn
        • DeleteEntry
          DeleteEntry
        • IntegerEntry
          IntegerEntry
        • Issue
          Issue
        • Lease
          Lease
        • LeaseCancel
          LeaseCancel
        • Reissue
          Reissue
        • ScriptTransfer
          ScriptTransfer
        • SponsorFee
          SponsorFee
        • StringEntry
          StringEntry
        Script Actions
      • Common Structures
        • Address
          Address
        • Alias
          Alias
        • Asset
          Asset
        • AssetPair
          AssetPair
        • AttachedPayment
          AttachedPayment
        • BalanceDetails
          BalanceDetails
        • BlockInfo
          BlockInfo
        • Invocation
          Invocation
        • Order
          Order
        • Transfer
          Transfer
        Common Structures
      • Transaction Structures
        • BurnTransaction
          BurnTransaction
        • CreateAliasTransaction
          CreateAliasTransaction
        • DataTransaction
          DataTransaction
        • ExchangeTransaction
          ExchangeTransaction
        • GenesisTransaction
          GenesisTransaction
        • InvokeScriptTransaction
          InvokeScriptTransaction
        • IssueTransaction
          IssueTransaction
        • LeaseCancelTransaction
          LeaseCancelTransaction
        • LeaseTransaction
          LeaseTransaction
        • MassTransferTransaction
          MassTransferTransaction
        • ReissueTransaction
          ReissueTransaction
        • SetAssetScriptTransaction
          SetAssetScriptTransaction
        • SetScriptTransaction
          SetScriptTransaction
        • SponsorFeeTransaction
          SponsorFeeTransaction
        • TransferTransaction
          TransferTransaction
        • UpdateAssetInfoTransaction
          UpdateAssetInfoTransaction
        Transaction Structures
      Structures
    • Built-in Variables
      Built-in Variables
    • Built-in Functions
      • Account Data Storage Functions
        Account Data Storage Functions
      • Blockchain Functions
        Blockchain Functions
      • Byte Array Functions
        Byte Array Functions
      • Converting Functions
        Converting Functions
      • Data Transaction Functions
        Data Transaction Functions
      • Decoding Functions
        Decoding Functions
      • Encoding Functions
        Encoding Functions
      • Exception Functions
        Exception Functions
      • Hashing Functions
        Hashing Functions
      • dApp-to-dApp Invocation Function
        dApp-to-dApp Invocation Function
      • List Functions
        List Functions
      • Math Functions
        Math Functions
      • String Functions
        String Functions
      • Union Functions
        Union Functions
      • Verification Functions
        Verification Functions
      Built-in Functions
    • Operators
      Operators
    • Limitations
      • Data Weight
        Data Weight
      Limitations
    Version 5 (Stagenet)
  • Ride Components
    Ride Components
  • Script performance tests
    Script performance tests
      • English
      • Русский
      On this page
        • Environment Functions Benchmark
        • Waves Environment Benchmark
        • Language Serde Benchmark
        • Script Estimator Benchmark
        • Script Evaluator Benchmark
        • State Synthetic Benchmark
        • Final Results
      waves_logo Docs

          # Script Performance Tests

          We conducted performance tests for all aspects of our scripts.
          For this purpose, we developed an benchmark subproject with JMH (opens new window) that computes the complexity of scripts after compilation phase by AST (Abstract Syntax Tree) traversal in special complexity units.

          Complexity units is a measure of the script's relative cost: we found out the most expensive operation in terms of computational complexity and defined it equal to 100 complexity units. In every test, we conducted 10 tests and calculated the average cost.

          The performance tests' results are the following:

          # Environment Functions Benchmark

          Functions used in the script that do not refer to the state:

          Benchmark Score Error
          addressFromPublicKey 15,457.000 ns/op ± 1,551.809 ns/op
          addressFromString_full 28,437.102 ns/op ± 706.255 ns/op
          base58_26_encode 2,207.600 ns/op ± 34.466 ns/op
          base58_decode_full 18,645.203 ns/op ± 415.800 ns/op
          base58_encode 12,243.466 ns/op ± 197.687 ns/op
          blake2b256 7,991.033 ns/op ± 438.591 ns/op
          curve25519_full 628,001.764 ns/op ± 35,875.443 ns/op
          curve25519_generateKeypair 95,835.192 ns/op ± 4,453.657 ns/op
          curve25519_sign_full 303,429.901 ns/op ± 6,683.234 ns/op
          keccak256 27,588.387 ns/op ± 1,002.837 ns/op
          random_bytes_500 1,188.761 ns/op ± 41.945 ns/op
          secureHash 10,292.214 ns/op ± 233.883 ns/op
          sha256 3,633.718 ns/op ± 142.837 ns/op

          Where:

          • The _full suffix means that we create an array of N random bytes, then we either code it and decode it, or we sign it and check it.
          • base58_26_encode - the test for 26 bytes.
          • base58_decode_full,base58_encode - tests for 64 bytes.
          • curve25519_sign_full, curve25519_full - tests for 512 bytes.

          # Waves Environment Benchmark

          Functions used in the script that refer to the state:

          Benchmark Score Error
          accountBalanceOf_asset 10,887.166 ns/op ± 490.024 ns/op
          accountBalanceOf_waves 12,837.177 ns/op ± 46.377 ns/op
          data 12,154.862 ns/op ± 666.479 ns/op
          resolveAddress 7,925.741 ns/op ± 114.994 ns/op
          transactionById 70,485.131 ns/op ± 3,587.244 ns/op
          transactionHeightById 66,644.724 ns/op ± 1,663.940 ns/op

          # Language Serde Benchmark

          Processes of serialization and deserialization of the script:

          Benchmark Score Error
          serialize 572,441.780 ns/op ± 241,711.329 ns/op
          deserialize 492,556.077 ns/op ± 46,122.237 ns/op

          # Script Estimator Benchmark

          In this test, we used a script, which size is about 1 kB. It contains sums of 100 numbers and one comparison operation. Here the script's complexity computation is presented:

          Benchmark Score Error
          apply 130,286.995 ns/op ± 3,544.940 ns/op

          # Script Evaluator Benchmark

          The execution time of the script described in the previous section:

          Benchmark Score Error
          apply 172,482.796 ns/op ± 4,170.202 ns/op

          # State Synthetic Benchmark

          Let's Compare the applying process for a block with 5,000 tx for a scripted account and for regular one:

          Benchmark Score Error
          appendBlock_smart 2,861.589 ms/op ± 108.005 ms/op
          appendBlock 2,069.613 ms/op ± 449.040 ms/op

          # Final Results

          The most expensive functions are:

          • base58
          • sigVerify

          As a result, we define the following constraint for a script cost: a script must have a size of** no more then 8 kB** and it must be faster than 20 executions of sigVerify, which is the most expensive operation.
          The fixed fee for each scripted unit is equal to 400,000 wavelets (Waves coins, 100,000,000 wavelets = 1 Wave).
          For example, if you use a scripted asset (smart asset) then you pay 400,000 wavelets, if you also have a scripted transaction then you have to pay 2 * 400,000 wavelets.

          Ride Components
          Ride Components