Skip to content

Solidity implementation of Queue (PriorityQueue, CircularQueue)

License

Notifications You must be signed in to change notification settings

BRAIN-chain/queue-contract

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TL;DR

$ npx hardhat test benchmark/gas.js --network hardhat

    Queue

Min: 29552
Max: 46652
Average (std): 29572.87912087912087912 (597.157457748190641764 = sqrt(356597.029344282091534838))
Median: 29552
      ✔ Push (11988ms)

Min: 12568
Max: 29668
Average (std): 12588.87912087912087912 (597.157457748190641764 = sqrt(356597.029344282091534838))
Median: 12568
      ✔ Pop (5822ms)

    PriorityQueue

Min: 62468
Max: 116058
Average (std): 69990.844932844932844932 (9202.242706903575156607 = sqrt(84681270.836760038225239689))
Median: 68682
      ✔ Push (7178ms)

Min: 22367
Max: 105269
Average (std): 89429.67155067155067155 (12942.169007308348399696 = sqrt(167499738.613732760252906772))
Median: 92872
      ✔ Pop (10054ms)

Queue

PriorityQueue and CircularQueue.

  • solc: 0.6.12

Test

$ npx hardhat node
# or
$ ganachi-cli
$ npx hardhat test benchmark/Queues.js --network localhost

  Queues
    Queue
Tester:  0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 (10000 ETH)
Deploy Queue:    0x129955157BE2622EbB0a7bEBC990216C63069973
Deploy PriorityQueue:    0x2E80eF24fA1938D4e2F01A564CaC98c77AaAfaa2
      ✓ Push (43314229 gas)
      ✓ Pop (23830071 gas)
    PriorityQueue
      ✓ Push (75137628 gas)
      ✓ Pop (82689318 gas)

·----------------------------|---------------------------|-------------|----------------------------·
|    Solc version: 0.6.12    ·  Optimizer enabled: true  ·  Runs: 200  ·  Block limit: 6718946 gas  │
·····························|···························|·············|·····························
|  Methods                                                                                          │
··················|··········|·············|·············|·············|··············|··············
|  Contract       ·  Method  ·  Min        ·  Max        ·  Avg        ·  # calls     ·  usd (avg)  │
··················|··········|·············|·············|·············|··············|··············
|  CircularQueue  ·  pop     ·      29013  ·      46113  ·      29034  ·         820  ·          -  │
··················|··········|·············|·············|·············|··············|··············
|  CircularQueue  ·  push    ·      51324  ·      68424  ·      51345  ·         820  ·          -  │
··················|··········|·············|·············|·············|··············|··············
|  PriorityQueue  ·  pop     ·      34909  ·     116942  ·     100861  ·         819  ·          -  │
··················|··········|·············|·············|·············|··············|··············
|  PriorityQueue  ·  push    ·      84353  ·     137955  ·      91699  ·         820  ·          -  │
··················|··········|·············|·············|·············|··············|··············
|  Deployments               ·                                         ·  % of limit  ·             │
·····························|·············|·············|·············|··············|··············
|  CircularQueue             ·          -  ·          -  ·     165973  ·       2.5 %  ·          -  │
·····························|·············|·············|·············|··············|··············
|  PriorityQueue             ·          -  ·          -  ·     379664  ·       5.7 %  ·          -  │
·----------------------------|-------------|-------------|-------------|--------------|-------------·

  4 passing (8m)

References

About

Solidity implementation of Queue (PriorityQueue, CircularQueue)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published