modify test data add fluc and plt

This commit is contained in:
lnk
2025-06-16 08:39:22 +08:00
parent a33418113a
commit 05e3d85798

View File

@@ -40,6 +40,11 @@ using namespace std;
#include "../log4cplus/log4.h"//lnk添加log4 #include "../log4cplus/log4.h"//lnk添加log4
#include <cstring> #include <cstring>
//用于测试时防止数据激增
#ifndef apr_time_from_msec
#define apr_time_from_msec(ms) ((apr_time_t)(ms) * 1000)
#endif
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif /* __cplusplus */ #endif /* __cplusplus */
@@ -6058,7 +6063,21 @@ void rocketmq_test_300(int mpnum,int front_index,int type) {
data.mp_id = "0"; data.mp_id = "0";
// 读取文件内容 // 读取文件内容
std::ifstream file("long_string.txt"); // 文件中存储长字符串 //std::ifstream file("long_string.txt"); // 文件中存储长字符串
std::vector<std::string> filenames;
filenames.push_back("long_string.txt");
filenames.push_back("PLT_string.txt");
filenames.push_back("fluc_string.txt");
filenames.push_back("qvvr_string.txt");
for (std::vector<std::string>::iterator it = filenames.begin(); it != filenames.end(); ++it) {
const std::string& filename = *it;
std::ifstream file(filename.c_str());
if (!file.is_open()) {
std::cerr << "跳过无法打开的文件: " << filename << std::endl;
continue;
}
std::stringstream buffer; std::stringstream buffer;
buffer << file.rdbuf(); buffer << file.rdbuf();
std::string file_contents = buffer.str(); // 获取文件内容 std::string file_contents = buffer.str(); // 获取文件内容
@@ -6085,7 +6104,7 @@ void rocketmq_test_300(int mpnum,int front_index,int type) {
// 循环发送 300 条消息 // 循环发送 300 条消息
if(type == 0){ if(type == 0){
std::cout << " use ledger send msg " << std::endl; std::cout << " use ledger send msg " << std::endl;
for (int i = 0; (total_messages != 0 && g_front_seg_index == 1 && g_node_id == 100) && i < g_node->n_clients; ++i) { for (int i = 0; (total_messages > 0 && g_front_seg_index == 1 && g_node_id == 100) && i < g_node->n_clients; ++i) {
ied = (ied_t*)g_node->clients[i]; ied = (ied_t*)g_node->clients[i];
if(ied != NULL){ if(ied != NULL){
@@ -6143,6 +6162,14 @@ void rocketmq_test_300(int mpnum,int front_index,int type) {
// 输出调试信息 // 输出调试信息
std::cout << "Sent message " << (i + 1) << " with Monitor " << data.monitor_id << " and TIME " << modified_time << std::endl; std::cout << "Sent message " << (i + 1) << " with Monitor " << data.monitor_id << " and TIME " << modified_time << std::endl;
/*int sleeptime = 6000/total_messages;//终端为单位
if(sleeptime > 50){
apr_sleep(apr_time_from_msec(50)); // 添加毫秒延时
}
else{
apr_sleep(apr_time_from_msec(6000/total_messages)); // 添加毫秒延时
}*/
} }
} }
} }
@@ -6150,7 +6177,7 @@ void rocketmq_test_300(int mpnum,int front_index,int type) {
else{ else{
std::cout << " use monitor + number send msg " << std::endl; std::cout << " use monitor + number send msg " << std::endl;
for (int i = 0; (total_messages != 0 && g_front_seg_index == 1 && g_node_id == 100) && i < total_messages; ++i) { for (int i = 0; (total_messages > 0 && g_front_seg_index == 1 && g_node_id == 100) && i < total_messages; ++i) {
// 修改 Monitor 值 // 修改 Monitor 值
char monitor_id[256] = {}; char monitor_id[256] = {};
@@ -6190,10 +6217,19 @@ void rocketmq_test_300(int mpnum,int front_index,int type) {
// 输出调试信息 // 输出调试信息
std::cout << "Sent message " << (i + 1) << " with Monitor " << data.monitor_id << " and TIME " << modified_time << std::endl; std::cout << "Sent message " << (i + 1) << " with Monitor " << data.monitor_id << " and TIME " << modified_time << std::endl;
/*int sleeptime = 60000/total_messages;//监测点为单位
if(sleeptime > 50){
apr_sleep(apr_time_from_msec(50)); // 添加毫秒延时
}
else{
apr_sleep(apr_time_from_msec(60000/total_messages)); // 添加毫秒延时
}*/
} }
} }
std::cout << "Finished sending " << total_messages << " messages." << std::endl; std::cout << "Finished sending " << total_messages << " messages." << std::endl;
}
} }
///////////////////////////////////////////////////////////////////////////////lnk实时日志部分20250205 ///////////////////////////////////////////////////////////////////////////////lnk实时日志部分20250205