|
| 1 | +// Copyright 2020 Kodebox, Inc. |
| 2 | +// This file is part of CodeChain. |
| 3 | +// |
| 4 | +// This program is free software: you can redistribute it and/or modify |
| 5 | +// it under the terms of the GNU Affero General Public License as |
| 6 | +// published by the Free Software Foundation, either version 3 of the |
| 7 | +// License, or (at your option) any later version. |
| 8 | +// |
| 9 | +// This program is distributed in the hope that it will be useful, |
| 10 | +// but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | +// GNU Affero General Public License for more details. |
| 13 | +// |
| 14 | +// You should have received a copy of the GNU Affero General Public License |
| 15 | +// along with this program. If not, see <https://www.gnu.org/licenses/>. |
| 16 | + |
| 17 | +import { SDK } from "codechain-sdk"; |
| 18 | +(async () => { |
| 19 | + const sdk = new SDK({ |
| 20 | + server: "http://localhost:8080", |
| 21 | + networkId: "tc" |
| 22 | + }); |
| 23 | + |
| 24 | + const bundleSize = 10000; |
| 25 | + |
| 26 | + const transactions = []; |
| 27 | + const startTime = new Date(); |
| 28 | + console.log(`Start at: ${startTime}`); |
| 29 | + for (let i = 0; i < bundleSize; i++) { |
| 30 | + const transaction = sdk.core.createPayTransaction({ |
| 31 | + recipient: "tccqyqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqpqc2ul2h", |
| 32 | + quantity: 1, |
| 33 | + }).sign({ |
| 34 | + secret: "ede1d4ccb4ec9a8bbbae9a13db3f4a7b56ea04189be86ac3a6a439d9a0a1addd", |
| 35 | + seq: i, |
| 36 | + fee: 100, |
| 37 | + }); |
| 38 | + transactions.push(transaction) |
| 39 | + } |
| 40 | + const endTime = new Date(); |
| 41 | + console.log(`End at: ${endTime}`); |
| 42 | + const throughput = |
| 43 | + (bundleSize * 1000.0) / (endTime.getTime() - startTime.getTime()); |
| 44 | + console.log( |
| 45 | + `Elapsed time (ms): ${endTime.getTime() - startTime.getTime()}` |
| 46 | + ); |
| 47 | + console.log(`throughput: ${throughput}`); |
| 48 | +})().catch(console.error); |
0 commit comments