-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
100 lines (94 loc) · 2.32 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
const {
Worker,
isMainThread,
parentPort,
workerData,
} = require("worker_threads");
const {
user1Client,
user1AccountId,
user2AccountId,
user2Client,
} = require("./accountSet");
const SendMessage = require("./sendMessage");
const TransferFunds = require("./transferFunds");
const message1 = "L";
const message10 = "Lorem ipsu";
const message100 =
"Lorem ipsum egestas lorem aliquam sapien, vivamus taciti innunc Lorem ipsum egestas lorem aliquam se";
const numberOfThreads = 1;
const numberOfTransactions = 1;
const typeTransaction = "transferFunds";
// const typeTransaction = "sendMessage";
if (isMainThread) {
for (let x = 1; x <= numberOfThreads; x++) {
const idThread = 100 + x;
const worker = new Worker(__filename, {
workerData: {
numberOfTransactions,
byteSize: 1,
idThread,
numberOfThreads,
},
});
worker.once("message", function () {
console.log("Thread worker id: " + worker.threadId + " finished");
});
worker.on("error", console.error);
console.log("Iniciando worker id: " + worker.threadId);
}
} else {
if (!workerData) return;
executor();
}
async function executor() {
const numberOfTransactions = workerData.numberOfTransactions;
const byteSize = workerData.byteSize;
const idThread = workerData.idThread;
const nroThreads = workerData.numberOfThreads;
if (typeTransaction === "transferFunds") {
const transfer = new TransferFunds();
transfer.transferFunds(
user1AccountId,
user2AccountId,
user1Client,
user2Client,
numberOfTransactions,
idThread,
nroThreads
);
} else {
const messager = new SendMessage();
if (byteSize === 1) {
messager.getTopicId(
user1Client,
message1,
numberOfTransactions,
byteSize,
nroThreads
);
}
if (byteSize === 10) {
messager.getTopicId(
user1Client,
message10,
numberOfTransactions,
byteSize,
nroThreads
);
}
if (byteSize === 100) {
messager.getTopicId(
user1Client,
message100,
numberOfTransactions,
byteSize,
nroThreads
);
}
}
parentPort.postMessage("Concluded");
}
//https://hedera.com/explorers
//https://app.dragonglass.me/hedera/home
//https://www.speedtest.net/