Skip to content

Commit da9fdd8

Browse files
committed
update new tps
1 parent 2d963a3 commit da9fdd8

8 files changed

+1767
-46
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
*.log
2+
*.out
3+
*.exe

client.go

+8-2
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,10 @@ func parse(jsonBytes []byte, transfer_type string) (int, time.Duration, error) {
9494
var test RPCResult
9595

9696
json.Unmarshal(value["receipt"], &test)
97-
fmt.Println(string(value["receipt"]))
97+
//fmt.Println(string(value["receipt"]))
9898
if len(test.Result) != 0 {
9999
result += len(test.Result)
100-
fmt.Println(string(value["receipt"]))
100+
//fmt.Println(string(value["receipt"]))
101101
}
102102

103103
} else if transfer_type == "InChain" {
@@ -385,6 +385,7 @@ func (c EthClient) Erc20TransferFrom(ctx context.Context, privHex string, nonce
385385
//res, err := erc20Instance.TransferFrom(auth, fromAddress, toAddress, big.NewInt(int64(tokenAmount)))
386386

387387
res, err := erc20Instance.Transfer(auth, toAddress, big.NewInt(int64(tokenAmount)))
388+
388389
//fmt.Println(res.Hash().Hex())
389390
if err != nil {
390391
return common.BytesToHash([]byte("")), err
@@ -482,9 +483,14 @@ func (c EthClient) CrossChainTNT20Transfer(ctx context.Context, privHex string,
482483
// fmt.Println(receipt.Logs[2].Data)
483484
//resolveNum := Resolve(receipt.Logs[2].Data)
484485

486+
if CountNum == 0 {
487+
startTime = time.Now()
488+
}
485489
CountNum += 1
486490
if CountNum%100 == 0 {
487491
fmt.Println("already send ", CountNum)
492+
fmt.Println("send 100 txes use", time.Since(startTime))
493+
startTime = time.Now()
488494
}
489495
return res.Hash(), nil
490496
}

main.go

+14-13
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ var (
6363
avgLatency time.Duration
6464
mutex sync.Mutex
6565
CountNum int
66+
startTime time.Time
6667
chainID = big.NewInt(360001) // 366 360777
6768
Erc20Address = ""
6869
TokenBankAddress = "0x47e9Fbef8C83A1714F1951F142132E6e90F5fa5D" // subchain 0x47e9Fbef8C83A1714F1951F142132E6e90F5fa5D mainchain 0x2Ce636d6240f8955d085a896e12429f8B3c7db26
@@ -124,22 +125,22 @@ func main() {
124125
crossSubChainTNT20StressTest(&client_list, ctx)
125126
}
126127
if clientID == 0 {
127-
//var newclient1 EthClient
128-
var newclient2 EthClient
128+
var newclient1 EthClient
129+
//var newclient2 EthClient
129130
//在跨链测试时需要开一个新的client在另一条链进行监测
130-
//newclient1, err = NewClient("http://10.10.1.1:16888/rpc", "http://10.10.1.9:18888/rpc") // subchain 16900 19888 sidechain "http://127.0.0.1:17900/rpc", "http://127.0.0.1:19988/rpc" mainchain "http://127.0.0.1:16888/rpc", "http://127.0.0.1:18888/rpc"
131-
//newclient1.transfer_type = "CrossChain"
131+
newclient1, err = NewClient("http://10.10.1.1:16888/rpc", "http://10.10.1.9:18888/rpc") // subchain 16900 19888 sidechain "http://127.0.0.1:17900/rpc", "http://127.0.0.1:19988/rpc" mainchain "http://127.0.0.1:16888/rpc", "http://127.0.0.1:18888/rpc"
132+
newclient1.transfer_type = "CrossChain"
132133
//开始TPS以及延迟测量
133-
//fmt.Println("-----------Start Measuring----------")
134-
//tps.StartTPSMeasuring(context.Background(), &newclient1, &tpsClosing, &idlingDuration, logger, 1)
135-
newclient2, err = NewClient("http://127.0.0.1:16900/rpc", "http://127.0.0.1:19888/rpc") // subchain 16900 19888 sidechain "http://127.0.0.1:17900/rpc", "http://127.0.0.1:19988/rpc" mainchain "http://127.0.0.1:16888/rpc", "http://127.0.0.1:18888/rpc"
136-
newclient2.transfer_type = "InChain"
137-
// //开始TPS以及延迟测量
138134
fmt.Println("-----------Start Measuring----------")
139-
if err = tps.StartTPSMeasuring(context.Background(), &newclient2, &tpsClosing, &idlingDuration, logger, 2); err != nil {
140-
fmt.Println("err StartTPSMeasuring:", err)
141-
logger.Fatal("err StartTPSMeasuring: ", err)
142-
}
135+
tps.StartTPSMeasuring(context.Background(), &newclient1, &tpsClosing, &idlingDuration, logger, 1)
136+
// newclient2, err = NewClient("http://127.0.0.1:16900/rpc", "http://127.0.0.1:19888/rpc") // subchain 16900 19888 sidechain "http://127.0.0.1:17900/rpc", "http://127.0.0.1:19988/rpc" mainchain "http://127.0.0.1:16888/rpc", "http://127.0.0.1:18888/rpc"
137+
// newclient2.transfer_type = "InChain"
138+
// // //开始TPS以及延迟测量
139+
// fmt.Println("-----------Start Measuring----------")
140+
// if err = tps.StartTPSMeasuring(context.Background(), &newclient2, &tpsClosing, &idlingDuration, logger, 2); err != nil {
141+
// fmt.Println("err StartTPSMeasuring:", err)
142+
// logger.Fatal("err StartTPSMeasuring: ", err)
143+
// }
143144
} else {
144145
time.Sleep(mesuringDuration)
145146
}

out.txt

+1,718
Large diffs are not rendered by default.

stressCross.go

+8-7
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"fmt"
77
"log"
88
"sync/atomic"
9+
"time"
910

1011
"github.com/blockchain-tps-test/samples/theta/tps"
1112
"github.com/pkg/errors"
@@ -235,7 +236,7 @@ func crossSubChainTNT20StressTest(client *[]EthClient, ctx context.Context) {
235236
fmt.Println("have send 100")
236237

237238
}
238-
//time.Sleep(time.Duration(interval) * time.Millisecond)
239+
time.Sleep(time.Duration(interval) * time.Millisecond)
239240
//if count%crossPercentage == 0 {
240241
queue.Push(&EthTask{
241242
to: "0x27F6F1bb3e2977c3CB014e7d4B5639bB133A6032",
@@ -244,12 +245,12 @@ func crossSubChainTNT20StressTest(client *[]EthClient, ctx context.Context) {
244245
transfer_type: "CrossChain",
245246
})
246247
// } else {
247-
// queue.Push(&EthTask{
248-
// to: "0x27F6F1bb3e2977c3CB014e7d4B5639bB133A6032",
249-
// amount: 1,
250-
// tokenId: int64(count),
251-
// transfer_type: "InChain",
252-
// })
248+
// queue.Push(&EthTask{
249+
// to: "0x27F6F1bb3e2977c3CB014e7d4B5639bB133A6032",
250+
// amount: 1,
251+
// tokenId: int64(count),
252+
// transfer_type: "InChain",
253+
// })
253254
// }
254255

255256
//count++

test.py

+13-21
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,13 @@
1-
def calculate_sum_from_log(filename):
2-
total_sum = 0
3-
4-
with open(filename, 'r') as file:
5-
for line in file:
6-
if 'maxNumsTxs:' in line:
7-
parts = line.split('maxNumsTxs:')
8-
if len(parts) > 1:
9-
num_str = parts[1].strip()
10-
try:
11-
num = int(num_str)
12-
total_sum += num
13-
except ValueError:
14-
pass
15-
16-
return total_sum
17-
18-
19-
filename = 'output.log'
20-
sum_maxNumsTxs = calculate_sum_from_log(filename)
21-
print(f"Sum of maxNumsTxs: sum_maxNumsTxs={sum_maxNumsTxs}")
1+
import re
2+
3+
# 定义正则表达式模式
4+
pattern = r'.*map size.*'
5+
6+
# 打开输入文件和输出文件
7+
with open('./outputmain.log', 'r') as input_file, open('out.txt', 'w') as output_file:
8+
# 逐行读取输入文件
9+
for line in input_file:
10+
# 使用正则表达式匹配每一行
11+
if re.match(pattern, line):
12+
# 如果匹配成功,将该行写入输出文件
13+
output_file.write(line)

test1.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ def calculate_tx_num_sum(filename, start_height, end_height):
3131
return total_tx_num
3232

3333

34-
filename = 'output.log'
35-
start_height = 36
36-
end_height = 79
34+
filename = 'output1'
35+
start_height = 56
36+
end_height = 110
3737
sum_tx_num = calculate_tx_num_sum(filename, start_height, end_height)
3838
print(
3939
f"Sum of tx num from block.height {start_height} to {end_height}: {sum_tx_num}")

tpsclient-new

80 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)