Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
MetaProtocol
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nebula
MetaProtocol
Commits
e6fdb174
Commit
e6fdb174
authored
Nov 29, 2022
by
Ubuntu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix ethtx benchmark
parent
f9f37946
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
58 additions
and
43 deletions
+58
-43
grcp-tx_test.go
grcp-tx_test.go
+58
-43
No files found.
grcp-tx_test.go
View file @
e6fdb174
...
...
@@ -10,6 +10,8 @@ import (
"testing"
"time"
"sync"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
...
...
@@ -42,7 +44,12 @@ func (*RingServer) SendRawTransaction(ctx context.Context, req *base.EthTx) (*ri
return
&
ring
.
SendRawTransactionResponse
{},
nil
}
var
once
sync
.
Once
func
BenchmarkEthTx
(
b
*
testing
.
B
)
{
b
.
ReportAllocs
()
onceFunc
:=
func
()
{
lis
,
err
:=
net
.
Listen
(
"tcp"
,
":9006"
)
if
err
!=
nil
{
...
...
@@ -59,8 +66,13 @@ func BenchmarkEthTx(b *testing.B) {
b
.
Fatal
(
err
)
}
}()
}
b
.
ReportAllocs
()
once
.
Do
(
onceFunc
)
b
.
RunParallel
(
func
(
pb
*
testing
.
PB
)
{
for
pb
.
Next
()
{
conn
,
err
:=
grpc
.
Dial
(
"127.0.0.1:9006"
,
grpc
.
WithTransportCredentials
(
insecure
.
NewCredentials
()))
if
err
!=
nil
{
...
...
@@ -75,10 +87,10 @@ func BenchmarkEthTx(b *testing.B) {
local
,
_
:=
crypto
.
HexToECDSA
(
"FD5CC6F5E7E2805E920AC5DC83D5AF1106F9C92F0C04F9D5E1FD4261B4B4464A"
)
publicKey
:=
local
.
Public
()
publicKeyECDSA
,
_
:=
publicKey
.
(
*
ecdsa
.
PublicKey
)
fromAddress
:=
crypto
.
PubkeyToAddress
(
*
publicKeyECDSA
)
b
.
Log
(
fromAddress
)
//
publicKey := local.Public()
//
publicKeyECDSA, _ := publicKey.(*ecdsa.PublicKey)
//
fromAddress := crypto.PubkeyToAddress(*publicKeyECDSA)
//
b.Log(fromAddress)
remote
,
_
:=
crypto
.
GenerateKey
()
...
...
@@ -102,9 +114,8 @@ func BenchmarkEthTx(b *testing.B) {
inner
.
Recipient
=
&
addr
b
.
RunParallel
(
func
(
pb
*
testing
.
PB
)
{
// Each goroutine has its own bytes.Buffer.
for
pb
.
Next
()
{
// The loop body is executed b.N times total across all goroutines.
res
,
err
:=
c
.
SendRawTransaction
(
ctx
,
&
base
.
EthTx
{
Inner
:
&
inner
})
...
...
@@ -113,7 +124,9 @@ func BenchmarkEthTx(b *testing.B) {
b
.
Fatal
(
err
)
}
b
.
Logf
(
"Greeting: %v
\n
"
,
res
)
_
=
res
//b.Logf("Greeting: %v\n", res)
}
})
...
...
@@ -123,3 +136,5 @@ func pricedTransaction(to common.Address, nonce uint64, gaslimit uint64, gaspric
tx
,
_
:=
types
.
SignTx
(
types
.
NewTransaction
(
nonce
,
to
,
big
.
NewInt
(
100
),
gaslimit
,
gasprice
,
nil
),
types
.
HomesteadSigner
{},
key
)
return
tx
}
// go test -bench=.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment