confio / poe-contracts

Tgrade PoE smart contracts
Apache License 2.0
25 stars 8 forks source link

Benchmark `Ed25519Pubkey::to_address` #173

Closed maurolacy closed 2 years ago

maurolacy commented 2 years ago

Closes #172.

Results are:

$ cbench
    Finished bench [optimized] target(s) in 0.10s
     Running unittests (/Users/mauro/work/poe-contracts/target/release/deps/main-2e693b0c907ad080)
FCU9Ye9C0WbQLmjVQNB/341lqa8KyqRjAmiOeIqFIeI=.to_address() = DNo/R+88SQZpOxcO9lDrloxfSyw= (not cached) (65 SDK gas)
FCU9Ye9C0WbQLmjVQNB/341lqa8KyqRjAmiOeIqFIeI=.to_address() = N/A (cache miss) (58 SDK gas)
FCU9Ye9C0WbQLmjVQNB/341lqa8KyqRjAmiOeIqFIeI=.to_address() = DNo/R+88SQZpOxcO9lDrloxfSyw= (cached) (72 SDK gas)
FCU9Ye9C0WbQLmjVQNB/341lqa8KyqRjAmiOeIqFIeI=.to_address() = DNo/R+88SQZpOxcO9lDrloxfSyw= (cache hit) (70 SDK gas)
$ 

As we can see, computing the hash is not only cheap, it's faster than reading it from storage.

Better NOT to merge this, as it extends ExecuteMsg with some otherwise useless benchmarking helpers.

maurolacy commented 2 years ago

Closing this as mentioned.