| 468 | |
| 469 | template<typename F> |
| 470 | void StartCommonGeneration(const int64_t periodIn, const int64_t batchSizeIn, F generateFunc) { |
| 471 | |
| 472 | Stop(); |
| 473 | |
| 474 | period = periodIn; |
| 475 | batchSize = batchSizeIn; |
| 476 | if (period == 0 || batchSize == 0) |
| 477 | return; |
| 478 | |
| 479 | // reset message queue according to <period, batchSize> |
| 480 | // For example, generate 50(batchSize) transactions in 20(period), then |
| 481 | // we need to prepare 1000 * 10 / 20 * 50 = 25,000 transactions in 10 second. |
| 482 | // Actually, set the message queue's size to 50,000(double or up to 60,000). |
| 483 | GenTxQueue::SizeType size = 1000 * 10 * batchSize * 2 / period; |
| 484 | GenTxQueue::SizeType actualSize = size > MSG_QUEUE_MAX_LEN ? MSG_QUEUE_MAX_LEN : size; |
| 485 | |
| 486 | generationQueue = std::make_unique<GenTxQueue>(actualSize); |
| 487 | |
| 488 | generateThreads = new boost::thread_group(); |
| 489 | generateThreads->create_thread(generateFunc); |
| 490 | generateThreads->create_thread(boost::bind(&TpsTester::SendTx, this)); |
| 491 | } |
| 492 | |
| 493 | |
| 494 | }; |
no outgoing calls
no test coverage detected