Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
whqwjb
go-ethereum
提交
d8aaa3a2
G
go-ethereum
项目概览
whqwjb
/
go-ethereum
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
go-ethereum
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
d8aaa3a2
编写于
8月 14, 2017
作者:
M
Martin Holst Swende
提交者:
Péter Szilágyi
8月 14, 2017
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
core/vm: benchmarking of metro precompiles
上级
6131dd55
变更
2
展开全部
隐藏空白更改
内联
并排
Showing
2 changed file
with
341 addition
and
206 deletion
+341
-206
core/vm/contracts_test.go
core/vm/contracts_test.go
+302
-86
core/vm/instructions_test.go
core/vm/instructions_test.go
+39
-120
未找到文件。
core/vm/contracts_test.go
浏览文件 @
d8aaa3a2
此差异已折叠。
点击以展开。
core/vm/instructions_test.go
浏览文件 @
d8aaa3a2
package
vm
import
(
"fmt"
"math/big"
"testing"
...
...
@@ -64,126 +63,44 @@ func opBenchmark(bench *testing.B, op func(pc *uint64, evm *EVM, contract *Contr
}
}
func
precompiledBenchmark
(
addr
,
input
,
expected
string
,
gas
uint64
,
bench
*
testing
.
B
)
{
func
BenchmarkOpAdd64
(
b
*
testing
.
B
)
{
x
:=
"ffffffff"
y
:=
"fd37f3e2bba2c4f"
contract
:=
NewContract
(
AccountRef
(
common
.
HexToAddress
(
"1337"
)),
nil
,
new
(
big
.
Int
),
gas
)
p
:=
PrecompiledContractsMetropolis
[
common
.
HexToAddress
(
addr
)]
in
:=
common
.
Hex2Bytes
(
input
)
var
(
res
[]
byte
err
error
)
data
:=
make
([]
byte
,
len
(
in
))
bench
.
ResetTimer
()
for
i
:=
0
;
i
<
bench
.
N
;
i
++
{
contract
.
Gas
=
gas
copy
(
data
,
in
)
res
,
err
=
RunPrecompiledContract
(
p
,
data
,
contract
)
}
bench
.
StopTimer
()
//Check if it is correct
if
err
!=
nil
{
bench
.
Error
(
err
)
return
}
if
common
.
Bytes2Hex
(
res
)
!=
expected
{
bench
.
Error
(
fmt
.
Sprintf
(
"Expected %v, got %v"
,
expected
,
common
.
Bytes2Hex
(
res
)))
return
}
}
func
BenchmarkPrecompiledECDSA
(
bench
*
testing
.
B
)
{
var
(
addr
=
"01"
inp
=
"38d18acb67d25c8bb9942764b62f18e17054f66a817bd4295423adf9ed98873e000000000000000000000000000000000000000000000000000000000000001b38d18acb67d25c8bb9942764b62f18e17054f66a817bd4295423adf9ed98873e789d1dd423d25f0772d2748d60f7e4b81bb14d086eba8e8e8efb6dcff8a4ae02"
exp
=
"000000000000000000000000ceaccac640adf55b2028469bd36ba501f28b699d"
gas
=
uint64
(
4000000
)
)
precompiledBenchmark
(
addr
,
inp
,
exp
,
gas
,
bench
)
}
func
BenchmarkPrecompiledSha256
(
bench
*
testing
.
B
)
{
var
(
addr
=
"02"
inp
=
"38d18acb67d25c8bb9942764b62f18e17054f66a817bd4295423adf9ed98873e000000000000000000000000000000000000000000000000000000000000001b38d18acb67d25c8bb9942764b62f18e17054f66a817bd4295423adf9ed98873e789d1dd423d25f0772d2748d60f7e4b81bb14d086eba8e8e8efb6dcff8a4ae02"
exp
=
"811c7003375852fabd0d362e40e68607a12bdabae61a7d068fe5fdd1dbbf2a5d"
gas
=
uint64
(
4000000
)
)
precompiledBenchmark
(
addr
,
inp
,
exp
,
gas
,
bench
)
opBenchmark
(
b
,
opAdd
,
x
,
y
)
}
func
BenchmarkPrecompiledRipeMD
(
bench
*
testing
.
B
)
{
var
(
addr
=
"03"
inp
=
"38d18acb67d25c8bb9942764b62f18e17054f66a817bd4295423adf9ed98873e000000000000000000000000000000000000000000000000000000000000001b38d18acb67d25c8bb9942764b62f18e17054f66a817bd4295423adf9ed98873e789d1dd423d25f0772d2748d60f7e4b81bb14d086eba8e8e8efb6dcff8a4ae02"
exp
=
"0000000000000000000000009215b8d9882ff46f0dfde6684d78e831467f65e6"
gas
=
uint64
(
4000000
)
)
precompiledBenchmark
(
addr
,
inp
,
exp
,
gas
,
bench
)
}
func
BenchmarkOpAdd128
(
b
*
testing
.
B
)
{
x
:=
"ffffffffffffffff"
y
:=
"f5470b43c6549b016288e9a65629687"
func
BenchmarkPrecompiledIdentity
(
bench
*
testing
.
B
)
{
var
(
addr
=
"04"
inp
=
"38d18acb67d25c8bb9942764b62f18e17054f66a817bd4295423adf9ed98873e000000000000000000000000000000000000000000000000000000000000001b38d18acb67d25c8bb9942764b62f18e17054f66a817bd4295423adf9ed98873e789d1dd423d25f0772d2748d60f7e4b81bb14d086eba8e8e8efb6dcff8a4ae02"
exp
=
"38d18acb67d25c8bb9942764b62f18e17054f66a817bd4295423adf9ed98873e000000000000000000000000000000000000000000000000000000000000001b38d18acb67d25c8bb9942764b62f18e17054f66a817bd4295423adf9ed98873e789d1dd423d25f0772d2748d60f7e4b81bb14d086eba8e8e8efb6dcff8a4ae02"
gas
=
uint64
(
4000000
)
)
precompiledBenchmark
(
addr
,
inp
,
exp
,
gas
,
bench
)
opBenchmark
(
b
,
opAdd
,
x
,
y
)
}
func
BenchmarkPrecompiledModExp
(
bench
*
testing
.
B
)
{
var
(
addr
=
"05"
inp
=
"00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002003fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2efffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"
exp
=
"0000000000000000000000000000000000000000000000000000000000000001"
gas
=
uint64
(
4000000
)
)
precompiledBenchmark
(
addr
,
inp
,
exp
,
gas
,
bench
)
}
func
BenchmarkOpAdd256
(
b
*
testing
.
B
)
{
x
:=
"0802431afcbce1fc194c9eaa417b2fb67dc75a95db0bc7ec6b1c8af11df6a1da9"
y
:=
"a1f5aac137876480252e5dcac62c354ec0d42b76b0642b6181ed099849ea1d57"
func
BenchmarkPrecompiledBn256Add
(
bench
*
testing
.
B
)
{
var
(
addr
=
"06"
inp
=
"0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
exp
=
"00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
gas
=
uint64
(
4000000
)
)
precompiledBenchmark
(
addr
,
inp
,
exp
,
gas
,
bench
)
opBenchmark
(
b
,
opAdd
,
x
,
y
)
}
func
BenchmarkPrecompiledBn256ScalarMul
(
bench
*
testing
.
B
)
{
var
(
addr
=
"07"
inp
=
"000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
exp
=
"00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
gas
=
uint64
(
4000000
)
)
precompiledBenchmark
(
addr
,
inp
,
exp
,
gas
,
bench
)
}
func
BenchmarkOpSub64
(
b
*
testing
.
B
)
{
x
:=
"51022b6317003a9d"
y
:=
"a20456c62e00753a"
func
BenchmarkPrecompiledBn256Pairing
(
bench
*
testing
.
B
)
{
var
(
addr
=
"08"
inp
=
"1c76476f4def4bb94541d57ebba1193381ffa7aa76ada664dd31c16024c43f593034dd2920f673e204fee2811c678745fc819b55d3e9d294e45c9b03a76aef41209dd15ebff5d46c4bd888e51a93cf99a7329636c63514396b4a452003a35bf704bf11ca01483bfa8b34b43561848d28905960114c8ac04049af4b6315a416782bb8324af6cfc93537a2ad1a445cfd0ca2a71acd7ac41fadbf933c2a51be344d120a2a4cf30c1bf9845f20c6fe39e07ea2cce61f0c9bb048165fe5e4de877550111e129f1cf1097710d41c4ac70fcdfa5ba2023c6ff1cbeac322de49d1b6df7c2032c61a830e3c17286de9462bf242fca2883585b93870a73853face6a6bf411198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa"
exp
=
"0000000000000000000000000000000000000000000000000000000000000001"
gas
=
uint64
(
4000000
)
)
precompiledBenchmark
(
addr
,
inp
,
exp
,
gas
,
bench
)
opBenchmark
(
b
,
opSub
,
x
,
y
)
}
func
BenchmarkOp
Add
(
b
*
testing
.
B
)
{
x
:=
"
ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff
"
y
:=
"
ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff
"
func
BenchmarkOp
Sub128
(
b
*
testing
.
B
)
{
x
:=
"
4dde30faaacdc14d00327aac314e915d
"
y
:=
"
9bbc61f5559b829a0064f558629d22ba
"
opBenchmark
(
b
,
op
Add
,
x
,
y
)
opBenchmark
(
b
,
op
Sub
,
x
,
y
)
}
func
BenchmarkOpSub
(
b
*
testing
.
B
)
{
x
:=
"
ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff
"
y
:=
"
ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff
"
func
BenchmarkOpSub
256
(
b
*
testing
.
B
)
{
x
:=
"
4bfcd8bb2ac462735b48a17580690283980aa2d679f091c64364594df113ea37
"
y
:=
"
97f9b1765588c4e6b69142eb00d20507301545acf3e1238c86c8b29be227d46e
"
opBenchmark
(
b
,
opSub
,
x
,
y
)
}
...
...
@@ -195,16 +112,27 @@ func BenchmarkOpMul(b *testing.B) {
opBenchmark
(
b
,
opMul
,
x
,
y
)
}
func
BenchmarkOpDiv
(
b
*
testing
.
B
)
{
x
:=
"ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
y
:=
"ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
func
BenchmarkOpDiv256
(
b
*
testing
.
B
)
{
x
:=
"ff3f9014f20db29ae04af2c2d265de17"
y
:=
"fe7fb0d1f59dfe9492ffbf73683fd1e870eec79504c60144cc7f5fc2bad1e611"
opBenchmark
(
b
,
opDiv
,
x
,
y
)
}
func
BenchmarkOpDiv128
(
b
*
testing
.
B
)
{
x
:=
"fdedc7f10142ff97"
y
:=
"fbdfda0e2ce356173d1993d5f70a2b11"
opBenchmark
(
b
,
opDiv
,
x
,
y
)
}
func
BenchmarkOpDiv64
(
b
*
testing
.
B
)
{
x
:=
"fcb34eb3"
y
:=
"f97180878e839129"
opBenchmark
(
b
,
opDiv
,
x
,
y
)
}
func
BenchmarkOpSdiv
(
b
*
testing
.
B
)
{
x
:=
"
ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff
"
y
:=
"
ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff
"
x
:=
"
ff3f9014f20db29ae04af2c2d265de17
"
y
:=
"
fe7fb0d1f59dfe9492ffbf73683fd1e870eec79504c60144cc7f5fc2bad1e611
"
opBenchmark
(
b
,
opSdiv
,
x
,
y
)
}
...
...
@@ -315,12 +243,3 @@ func BenchmarkOpMulmod(b *testing.B) {
opBenchmark
(
b
,
opMulmod
,
x
,
y
,
z
)
}
//func BenchmarkOpSha3(b *testing.B) {
// x := "0"
// y := "32"
//
// opBenchmark(b,opSha3, x, y)
//
//
//}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录