Performance Comparison Test: AELF vs Ethereum
aelf’s performance on executing smart contracts is thousands of times faster than that of Ethereum
Author: Zongzhe Huang
- 1. Test Case and Code
- 2. Machine Configuration
- 3. Test Results
- 3.1 EVM
- 3.2 AELF
- 3.2.1 LoopDivAdd10M
- 3.2.2 LoopExpNop1M
As the development of aelf network matures, various types of tests are being conducted to pressure test the performance of the network in a number of different angles.
One of the more recent tests to check the advanced nature of the fundamental underlying technology of aelf, was to compare the performance of both Ethereum and aelf under identical environment.
The results were stunning. aelf’s contract execution efficiency was proven to be substantially higher than that of Ethereum’s EVM, aelf outpacing Ethereum by hundreds if not thousands of times in processing speed. Ethereum utilizes its EVM module to support contract execution while its 256 bit stack size and gas count contribute significantly to the overall performance. In contrast, aelf calls the contract through C# reflection allowing many unnecessary executions to be bypassed.
1. Test Case and Code
The test was conducted using Ethereum loop-DivAdd-10M.json and loop-exp-nop-1M.json.
ETH: Based on the official go implementation version https://github.com/ethereum/go-ethereum
AELF: Based on the official C# implementation version https://github.com/AElfProject/AElf
Test case, standard test for ETH: https://github.com/ethereum/tests/tree/develop/src/VMTestsFiller
Corresponding aelf test program:https://github.com/AElfProject/AElf/blob/dev/bench/AElf.Benchmark
2. Machine Configuration
Test Enviornment:
OS=ubuntu 16.04
QEMU Virtual CPU, 2 CPU, 2 logical and 2 physical cores
CPU MHz: 2194.916; cache size : 16384 KBaelf Test Environment:BenchmarkDotNet=v0.11.5
.NET Core SDK=2.2.203
[Host] : .NET Core 2.2.4 (CoreCLR 4.6.27521.02, CoreFX 4.6.27521.01), 64bit RyuJIT DEBUG
3. Test Results
LoopDivAdd10M: EVM takes 169 times longer than aelf
LoopExpNop1M: EVM takes 1223 times longer than aelf
3.1 EVM
The official go implementation version of the built-in test program execution results are as shown below.
LoopDivAdd10M:14.236813572s
LoopExpNop1M: 639.16568ms
3.2 AELF
LoopDivAdd10M: 84.01ms
LoopExpNop1M: 0.5225ms
3.2.1 LoopDivAdd10M
Dividing/Addition cycle 10 million times
Method:
public override DoubleValue LoopDivAdd(DivAddTestInput input)
{
var r = input.X;
for (uint i = 0; i < input.N; i++)
{
r /= input.Y;
r += input.K;
}
return new DoubleValue {Value = r};
}
Input:
new DivAddTestInput()
{
X = 100,
Y = 300,
K = 500,
N = 10000000
}
Result:
3.2.2 LoopExpNop1M
Method
public override Int32Value LoopExpNop(PerformanceTesteInput input)
{
for (uint i = 0; i < input.N; i++)
{
}
return new Int32Value {Value = input.Seed};
}
Input
new PerformanceTesteInput()
{
Exponent = 0,
Seed = _executeResult,
N = 1000000
}
Result:
In the case of the same test machine configuration, 10 million cycles of addition and division test, aelf only needs 84.01ms, 169 times higher than Ethereum EVM; 1 million empty loop, aelf only needs 0.5225 ms, which is 1223 times higher than Ethereum EVM.
When we just got the result of 500us, we were also surprised, it took 5ms to run this test program before. We thought it was because of this release, the optimization of this empty loop code. However, after decompilation, the corresponding logic is still there, and the data has no problem.