瀏覽代碼

增加脚本命令行传参的支持

jiyuhang 3 月之前
父節點
當前提交
9cc61fc0b7
共有 7 個文件被更改,包括 52 次插入487 次删除
  1. 5 1
      config.json
  2. 40 17
      main.sh
  3. 0 51
      monitor_online.py
  4. 0 416
      plot_bk.py
  5. 0 0
      plot_offline.py
  6. 0 2
      readme.md
  7. 7 0
      test/test_script.py

+ 5 - 1
config.json

@@ -1,3 +1,7 @@
 {
-  "test_script_dir": "./test/test_script.py"
+  "test_script_dir": "./test/test_script.py",
+  "args": {
+    "input":"input_file.txt",
+    "output":"output_file.txt"
+  }
 }

+ 40 - 17
main.sh

@@ -11,12 +11,13 @@ NC='\033[0m' # No Color
 # 默认参数
 RESULT_DIR="results"
 TEST_SCRIPT=""  # 待测试的脚本
+ARGS_SCRIPT="" # 待测试脚本的参数
 PSUTIL_SCRIPT="monitor_util.py"  # 监测工具脚本
 INTEGRATED_SCRIPT="integrate_results.py"  # 融合工具脚本
-PLOT_SCRIPT="plot.py"  # 画图工具脚本
+PLOT_SCRIPT="plot_offline.py"  # 画图工具脚本
 CPROFILE_OUTPUT="$RESULT_DIR/cprofile_output.prof"  # cProfile 结果文件
 MEMORY_PROFILE_OUTPUT="$RESULT_DIR/mprofile_output.dat"  # memory_profiler输出文件
-MEMORY_PLOT_OUTPUT="$RESULT_DIR/mprofile_memory_plot.png"  # memory_profiler 绘制的曲线图
+#MEMORY_PLOT_OUTPUT="$RESULT_DIR/mprofile_memory_plot.png"  # memory_profiler 绘制的曲线图
 FLAMEGRAPH_OUTPUT="$RESULT_DIR/pyspy_output.svg"  # py-spy 输出文件
 PSUTIL_OUTPUT="$RESULT_DIR/psutil_output.csv"  # psutil 输出文件
 INTEGRATED_REPORT="$RESULT_DIR/performance_analysis_report.json"  # 融合结果文件
@@ -58,29 +59,49 @@ show_step() {
 # 检查脚本文件是否存在
 check_script_exists() {
     if [ -f "config.json" ]; then
+        # 读取脚本路径
         TEST_SCRIPT=$(python -c "
 import json
 try:
     with open('config.json', 'r') as f:
         config = json.load(f)
-        print(config.get('test_script_dir', ''))
+        script_path = config.get('test_script_dir', '')
+        print(script_path)
 except Exception as e:
     print('')
 " 2>/dev/null)
 
         if [ -n "$TEST_SCRIPT" ]; then
-            log_info "从 config.json 读取测试脚本路径: $TEST_SCRIPT"
+            log_info "从 config.json 读取测试脚本: $TEST_SCRIPT"
         else
-            log_warning "config.json 中未找到有效的 test_script_dir 配置"
+            log_warning "config.json 中未找到有效的 test_script_dir"
             return 1
         fi
-    else
-        log_warning "未找到 config.json 配置文件"
+        # 确认脚本存在
+        if [ ! -f "$TEST_SCRIPT" ]; then
+        log_error "测试脚本 $TEST_SCRIPT 不存在"
         return 1
-    fi
+        fi
+        # 读取脚本参数
+        ARGS_SCRIPT=$(python -c "
+import json
+try:
+    with open('config.json', 'r') as f:
+        config = json.load(f)
+        args = config.get('args', {})
+        cmd_args = ' '.join('--{} {}'.format(k, v) for k, v in args.items())
+        print(cmd_args)
+except Exception as e:
+    print('')
+" 2>/dev/null)
+        if [ -n "$ARGS_SCRIPT" ]; then
+            log_info "从 config.json 读取脚本参数: $ARGS_SCRIPT"
+        else
+            log_warning "config.json 中未配置有效的 args"
+        fi
 
-    if [ ! -f "$TEST_SCRIPT" ]; then
-        log_error "测试脚本 $TEST_SCRIPT 不存在"
+    else
+        log_warning "未找到 config.json 配置文件"
         return 1
     fi
     sleep 2
@@ -103,7 +124,8 @@ run_cprofile() {
 
     # 将之前的结果删除
     rm -rf "$CPROFILE_OUTPUT"
-    if python -m cProfile -o "$CPROFILE_OUTPUT" "$TEST_SCRIPT"; then
+    log_info "键入指令: python -m cProfile -o $CPROFILE_OUTPUT $TEST_SCRIPT $ARGS_SCRIPT"
+    if python -m cProfile -o "$CPROFILE_OUTPUT" "$TEST_SCRIPT" $ARGS_SCRIPT; then
         log_success "cProfile 分析完成,结果保存至 $CPROFILE_OUTPUT"
         return 0
     else
@@ -132,7 +154,8 @@ run_memory_profiler() {
     rm -rf "$MEMORY_PROFILE_OUTPUT"
     # 运行内存分析
     if command -v mprof &> /dev/null; then
-        if mprof run --output "$MEMORY_PROFILE_OUTPUT" "$TEST_SCRIPT"; then
+        log_info "键入指令: mprof run --output $MEMORY_PROFILE_OUTPUT $TEST_SCRIPT $ARGS_SCRIPT"
+        if mprof run --output "$MEMORY_PROFILE_OUTPUT" "$TEST_SCRIPT" $ARGS_SCRIPT; then
             log_success "memory_profiler 分析完成,结果保存至 $MEMORY_PROFILE_OUTPUT"
             # 绘制内存占用曲线(弃用)
 #            log_info "绘制内存占用曲线"
@@ -175,14 +198,14 @@ run_py_spy() {
     if [[ "$OSTYPE" == "msys" ]] || [[ "$OSTYPE" == "win32" ]]; then
         # Windows环境下使用--nonblocking选项
         log_info "Windows环境下使用--nonblocking选项"
-        PYSPY_CMD="py-spy record -o $FLAMEGRAPH_OUTPUT --duration 35 --native --subprocesses --nonblocking -- python $TEST_SCRIPT"
+        PYSPY_CMD="py-spy record -o $FLAMEGRAPH_OUTPUT --duration 35 --native --subprocesses --nonblocking -- python $TEST_SCRIPT $ARGS_SCRIPT"
     elif [[ "$OSTYPE" == "linux-gnu"* ]]; then
         # Linux环境下使用sudo运行
         log_info "Linux环境下使用sudo运行py-spy"
-        PYSPY_CMD="sudo env \"PATH=\$PATH\" py-spy record -o $FLAMEGRAPH_OUTPUT --duration 35 --native --subprocesses -- python $TEST_SCRIPT"
+        PYSPY_CMD="sudo env \"PATH=\$PATH\" py-spy record -o $FLAMEGRAPH_OUTPUT --duration 35 --native --subprocesses -- python $TEST_SCRIPT $ARGS_SCRIPT"
     else
         # 其他Unix系统使用默认选项
-        PYSPY_CMD="py-spy record -o $FLAMEGRAPH_OUTPUT --duration 35 --native --subprocesses -- python $TEST_SCRIPT"
+        PYSPY_CMD="py-spy record -o $FLAMEGRAPH_OUTPUT --duration 35 --native --subprocesses -- python $TEST_SCRIPT $ARGS_SCRIPT"
     fi
     
     log_info "执行命令: $PYSPY_CMD"
@@ -216,8 +239,8 @@ run_psutil() {
   # 将之前的结果文件删除
   rm -rf "$PSUTIL_OUTPUT"
   # 在后台运行test_script.py并获取其PID
-  log_info "在后台启动 $TEST_SCRIPT ..."
-  python "$TEST_SCRIPT" &
+  log_info "在后台启动 $TEST_SCRIPT $ARGS_SCRIP ..."
+  python "$TEST_SCRIPT" $ARGS_SCRIPT &
   TEST_PID=$!
   
   # 等待一段时间确保进程已经完全启动

+ 0 - 51
monitor_online.py

@@ -1,54 +1,3 @@
 import sys
 import os
 sys.path.append(os.path.basename(__file__))
-from monitor_util import Monitor
-import psutil
-from datetime import datetime
-import subprocess
-from flask import Flask, render_template, request, jsonify
-from monitor_mnger import monitor_manager
-
-
-# 全局变量存储监控实例和监控状态
-app = Flask(__name__)
-
-@app.route('/monitor', methods=['GET', 'POST'])
-def monitor_control():
-    """监控控制接口"""
-    if request.method == 'GET':
-        # 返回监控界面
-        return render_template('monitor.html')
-    elif request.method == 'POST':
-        # 启动或停止监控
-        data = request.get_json()
-        if not data:
-            return jsonify({"status": "error", "message": "无效的请求数据"})
-
-        action = data.get('action')  # 获取行为
-        pid = data.get('pid')  # 获取进程id
-
-        # 参数检查
-        if not pid:
-            return jsonify({"status": "error", "message": "未提供PID参数"})
-        try:
-            pid = int(pid)
-        except ValueError:
-            return jsonify({"status": "error", "message": "PID必须是数字"})
-
-        # 开启或停止监控
-        if action == 'start':
-            # 启动监控
-            interval = data.get('interval', 2)
-            result = monitor_manager.start_monitoring(pid, interval)
-            return jsonify(result)
-
-        elif action == 'stop':
-            # 停止监控
-            result = monitor_manager.stop_monitoring(pid)
-            return jsonify(result)
-        else:
-            return jsonify({"status": "error", "message": "不支持的操作"})
-
-
-if __name__ == "__main__":
-    app.run(debug=True, host='0.0.0.0', port=5000)

+ 0 - 416
plot_bk.py

@@ -1,416 +0,0 @@
-import json
-import argparse
-import os.path
-import platform
-import matplotlib
-import matplotlib.pyplot as plt
-import numpy as np
-from datetime import datetime
-from matplotlib.font_manager import FontProperties
-
-def setup_chinese_font_support():
-    """根据操作系统环境设置中文字体支持"""
-    system = platform.system().lower()
-    
-    if system == 'windows':
-        # Windows系统字体设置
-        plt.rcParams['font.sans-serif'] = ['SimHei', 'FangSong', 'Arial Unicode MS']
-
-    elif system == 'linux':
-        # 检查是否在WSL环境中
-        plt.rcParams['font.sans-serif'] = ['WenQuanYi Micro Hei', 'Microsoft YaHei', 'SimSun']
-    plt.rcParams['axes.unicode_minus'] = False
-
-
-# 在导入后立即设置字体支持
-setup_chinese_font_support()
-
-def read_json(file_path):
-    with open(file_path, 'r', encoding='utf-8') as f:
-        data = json.load(f)
-    return data
-
-def plot_cprofile_table(ax, cprofile_data):
-    """绘制cProfile详细信息表格"""
-    if not cprofile_data or 'points' not in cprofile_data:
-        ax.text(0.5, 0.5, '无cProfile数据', ha='center', va='center', transform=ax.transAxes)
-        ax.set_title('函数运行详细信息')
-        return
-    
-    # 只取前15个最耗时的函数
-    fun_num = 15
-    points = cprofile_data['points'][:fun_num]
-    
-    # 准备表格数据
-    table_data = []
-    for point in points:
-        # 简化函数名显示
-        func_name = point['function'][1:-1]
-        func_name = func_name.split(',')[-1].strip()
-        func_name = func_name[1:-1]
-
-        # 限制函数名长度,但保留足够空间显示完整信息
-        func_name_display = func_name[:35] + '...' if len(func_name) > 35 else func_name
-        # 将数据点添加到表格
-        table_data.append([
-            func_name_display,
-            point['call_count'],
-            f"{point['total_time']:.6f}",
-            f"{point['cumulative_time']:.6f}"
-        ])
-    
-    # 创建表格
-    columns = ['函数名称', '调用次数', '总时间(s)', '累计时间(s)']
-    table = ax.table(cellText=table_data, colLabels=columns, cellLoc='center', loc='center')
-    table.auto_set_font_size(False)
-    table.set_fontsize(9)
-    table.scale(1, 1.5)
-    
-    # 设置表格样式
-    for i in range(len(columns)):
-        table[(0, i)].set_facecolor('#4CAF50')
-        table[(0, i)].set_text_props(weight='bold', color='white')
-    # 根据函数数量动态调整标题距离
-    # 每个函数行大约需要8个单位的高度,加上基础padding
-    pad_value = 8 + len(points) * 3
-    ax.set_title(f'函数运行详细信息 (Top {fun_num} 函数)', fontsize=14, pad=pad_value)
-    # 坐标轴掩藏
-    ax.set_xticks([])
-    ax.set_yticks([])
-    ax.spines['top'].set_visible(False)
-    ax.spines['right'].set_visible(False)
-    ax.spines['bottom'].set_visible(False)
-    ax.spines['left'].set_visible(False)
-
-
-def plot_cprofile_bar_chart(ax, cprofile_data):
-    """绘制cProfile总时间柱状图"""
-    if not cprofile_data or 'points' not in cprofile_data:
-        ax.text(0.5, 0.5, '无cProfile数据', ha='center', va='center', transform=ax.transAxes)
-        ax.set_title('函数运行总时间')
-        return
-    
-    # 只取前N个最耗时的函数
-    fun_num = 15
-    points = cprofile_data['points'][:fun_num]
-    
-    # 提取函数名和总时间
-    functions = []
-    total_times = []
-    
-    for point in points:
-        # 简化函数名显示
-        func_name = point['function'][1:-1]
-        func_name = func_name.split(',')[-1].strip()
-        func_name = func_name[1:-1]
-        
-        # 限制函数名长度
-        func_name_display = func_name[:35] + '...' if len(func_name) > 35 else func_name
-        functions.append(func_name_display)
-        total_times.append(point['total_time'])
-    
-    # 创建垂直柱状图,使用渐变色彩
-    x_pos = np.arange(len(functions))
-    colors = plt.cm.viridis(np.linspace(0, 1, len(functions)))
-    bars = ax.bar(x_pos, total_times, color=colors)
-    
-    # 设置坐标轴
-    ax.set_xticks(x_pos)
-    ax.set_xticklabels(functions, rotation=30, ha='right', fontsize=9)
-    ax.set_ylabel('总时间 (秒)', fontsize=12)
-    ax.set_title(f'函数运行总时间 (Top {fun_num} 函数)', fontsize=14, pad=20)
-    
-    # 改善网格线样式
-    ax.grid(axis='y', alpha=0.7, linestyle='--', linewidth=0.5)
-    ax.set_axisbelow(True)
-    
-    # 在柱状图上添加数值标签,优化显示效果
-    for bar, time in zip(bars, total_times):
-        height = bar.get_height()
-        ax.text(bar.get_x() + bar.get_width()/2., height,
-                f'{time:.6f}', ha='center', va='bottom', fontsize=8, 
-                rotation=0, weight='bold')
-    
-    # 添加边框
-    for spine in ax.spines.values():
-        spine.set_linewidth(0.5)
-
-def plot_memory_data(ax, memory_data):
-    """绘制内存使用数据"""
-    if not memory_data or 'points' not in memory_data:
-        ax.text(0.5, 0.5, '无内存数据', ha='center', va='center', transform=ax.transAxes)
-        ax.set_title('memory_profiler 内存使用情况')
-        return
-    
-    timestamps = [point['timestamp'] for point in memory_data['points']]
-    memory_values = [point['memory'] for point in memory_data['points']]
-    
-    # 转换时间戳为相对时间(秒)
-    start_time = timestamps[0] if timestamps else 0
-    relative_times = [t - start_time for t in timestamps]
-    
-    # 查找内存峰值及其位置
-    max_memory = max(memory_values) if memory_values else 0
-    max_index = memory_values.index(max_memory) if memory_values else 0
-    max_time = relative_times[max_index] if relative_times else 0
-    
-    # 绘制内存使用情况曲线
-    line, = ax.plot(relative_times, memory_values, marker='o', markersize=3, linewidth=1.5)
-    
-    # 在峰值点添加特殊标记
-    ax.plot(max_time, max_memory, marker='o', markersize=8, color='red',
-                          markerfacecolor='none', markeredgewidth=2, label=f'峰值: {max_memory:.2f} MB')
-    
-    ax.set_xlabel('时间 (秒)')
-    ax.set_ylabel('内存使用量 (MB)')
-    ax.set_title(f'进程内存使用情况 (峰值: {max_memory:.2f} MB at {max_time:.1f}s)')
-    ax.grid(True, alpha=0.3)
-    ax.legend()
-
-def plot_psutil_data(ax, psutil_data):
-    """绘制psutil系统资源数据"""
-    if not psutil_data or 'points' not in psutil_data:
-        ax.text(0.5, 0.5, '无进程资源数据', ha='center', va='center', transform=ax.transAxes)
-        ax.set_title('进程资源使用情况')
-        return
-    
-    points = psutil_data['points']
-    if not points:
-        ax.text(0.5, 0.5, '无进程资源数据', ha='center', va='center', transform=ax.transAxes)
-        ax.set_title('进程资源使用情况')
-        return
-    
-    # 提取数据并转换时间字符串为时间戳
-    timestamps = []
-    rss_values = []
-    vms_values = []
-    cpu_values = []
-    mem_pct_values = []
-    
-    for point in points:
-        # 解析时间字符串并转换为时间戳
-        try:
-            dt = datetime.strptime(point['now_time'], '%Y-%m-%d %H:%M:%S')
-            timestamps.append(dt.timestamp())
-        except ValueError:
-            # 如果解析失败,使用索引作为后备
-            timestamps.append(len(timestamps))
-            
-    # 转换时间戳为相对时间(秒)
-    start_time = timestamps[0] if timestamps else 0
-    relative_times = [t - start_time for t in timestamps]
-    
-    for point in points:
-        # 解析RSS内存值
-        rss_str = point['rss'].replace('MB', '')
-        try:
-            rss_values.append(float(rss_str))
-        except ValueError:
-            rss_values.append(0)
-            
-        # 解析VMS内存值
-        vms_str = point['vms'].replace('MB', '')
-        try:
-            vms_values.append(float(vms_str))
-        except ValueError:
-            vms_values.append(0)
-        
-        # 解析CPU百分比
-        cpu_str = point['cpu_pct'].replace('%', '')
-        try:
-            cpu_values.append(float(cpu_str))
-        except ValueError:
-            cpu_values.append(0)
-            
-        # 解析内存占用率
-        mem_pct_str = point['mem_pct'].replace('%', '')
-        try:
-            mem_pct_values.append(float(mem_pct_str))
-        except ValueError:
-            mem_pct_values.append(0)
-    
-    # 绘制双轴图
-    ax2 = ax.twinx()
-    
-    # 物理内存使用量(蓝色)
-    line1, = ax.plot(relative_times, rss_values, marker='o', color='blue', label='物理内存(RSS)')
-    # 虚拟内存使用量(绿色)
-    line3, = ax.plot(relative_times, vms_values, marker='^', color='green', label='虚拟内存(VMS)')
-    ax.set_xlabel('时间 (秒)')
-    ax.set_ylabel('内存使用量 (MB)', color='blue')
-    ax.tick_params(axis='y', labelcolor='blue')
-    
-    # CPU使用率(红色)和内存占用率(紫色)
-    line2, = ax2.plot(relative_times, cpu_values, marker='s', color='red', label='CPU使用率')
-    line4, = ax2.plot(relative_times, mem_pct_values, marker='d', color='purple', label='内存占用率')
-    ax2.set_ylabel('百分比 (%)', color='red')
-    ax2.tick_params(axis='y', labelcolor='red')
-    
-    # 合并图例
-    lines = [line1, line3, line2, line4]
-    labels = [l.get_label() for l in lines]
-    ax.legend(lines, labels, loc='upper left')
-    
-    ax.set_title('进程资源使用情况')
-    ax.grid(True, alpha=0.3)
-
-def plot_network_data(ax, psutil_data):
-    """绘制网络使用数据"""
-    if not psutil_data or 'points' not in psutil_data:
-        ax.text(0.5, 0.5, '无网络数据', ha='center', va='center', transform=ax.transAxes)
-        ax.set_title('系统网络使用情况')
-        return
-    
-    points = psutil_data['points']
-    if not points:
-        ax.text(0.5, 0.5, '无网络数据', ha='center', va='center', transform=ax.transAxes)
-        ax.set_title('系统网络使用情况')
-        return
-    
-    # 提取数据并转换时间字符串为时间戳
-    from datetime import datetime
-    timestamps = []
-    net_recv_values = []
-    net_send_values = []
-    
-    for point in points:
-        # 解析时间字符串并转换为时间戳
-        try:
-            dt = datetime.strptime(point['now_time'], '%Y-%m-%d %H:%M:%S')
-            timestamps.append(dt.timestamp())
-        except ValueError:
-            # 如果解析失败,使用索引作为后备
-            timestamps.append(len(timestamps))
-    
-    # 转换为相对时间(秒)
-    start_time = timestamps[0] if timestamps else 0
-    relative_times = [t - start_time for t in timestamps]
-    
-    for point in points:
-        # 解析网络接收值
-        net_recv_str = point['sys_net_recv'].replace('MB/s', '').replace('MB', '').replace(' ', '')
-        try:
-            net_recv_values.append(float(net_recv_str))
-        except ValueError:
-            net_recv_values.append(0)
-            
-        # 解析网络发送值
-        net_send_str = point['sys_net_send'].replace('MB/s', '').replace('MB', '').replace(' ', '')
-        try:
-            net_send_values.append(float(net_send_str))
-        except ValueError:
-            net_send_values.append(0)
-    
-    # 绘制网络使用情况
-    ax.plot(relative_times, net_recv_values, marker='o', color='blue', label='网络接收')
-    ax.plot(relative_times, net_send_values, marker='s', color='red', label='网络发送')
-    
-    ax.set_xlabel('时间 (秒)')
-    ax.set_ylabel('速率 (MB/s)')
-    ax.set_title('系统网络使用情况')
-    ax.grid(True, alpha=0.3)
-    ax.legend()
-
-def plot_disk_io_data(ax, psutil_data):
-    """绘制进程IO数据"""
-    if not psutil_data or 'points' not in psutil_data:
-        ax.text(0.5, 0.5, '无进程IO数据', ha='center', va='center', transform=ax.transAxes)
-        ax.set_title('进程IO情况')
-        return
-    
-    points = psutil_data['points']
-    if not points:
-        ax.text(0.5, 0.5, '无进程IO数据', ha='center', va='center', transform=ax.transAxes)
-        ax.set_title('进程IO情况')
-        return
-    
-    # 提取数据并转换时间字符串为时间戳
-    timestamps = []
-    disk_read_values = []
-    disk_write_values = []
-    
-    for point in points:
-        # 解析时间字符串并转换为时间戳
-        try:
-            dt = datetime.strptime(point['now_time'], '%Y-%m-%d %H:%M:%S')
-            timestamps.append(dt.timestamp())
-        except ValueError:
-            # 如果解析失败,使用索引作为后备
-            timestamps.append(len(timestamps))
-    
-    # 转换为相对时间(秒)
-    start_time = timestamps[0] if timestamps else 0
-    relative_times = [t - start_time for t in timestamps]
-    
-    for point in points:
-        # 解析磁盘读取值
-        disk_read_str = point['disk_read'].replace('MB/s', '').replace('MB', '').replace(' ', '')
-        try:
-            disk_read_values.append(float(disk_read_str))
-        except ValueError:
-            disk_read_values.append(0)
-            
-        # 解析磁盘写入值
-        disk_write_str = point['disk_write'].replace('MB/s', '').replace('MB', '').replace(' ', '')
-        try:
-            disk_write_values.append(float(disk_write_str))
-        except ValueError:
-            disk_write_values.append(0)
-    
-    # 绘制磁盘IO情况
-    ax.plot(relative_times, disk_read_values, marker='o', color='blue', label='磁盘读取')
-    ax.plot(relative_times, disk_write_values, marker='s', color='red', label='磁盘写入')
-    
-    ax.set_xlabel('时间 (秒)')
-    ax.set_ylabel('速率 (MB/s)')
-    ax.set_title('进程IO情况')
-    ax.grid(True, alpha=0.3)
-    ax.legend()
-
-def main():
-    parser = argparse.ArgumentParser(description='绘制性能分析结果图')
-    # parser.add_argument('--input','-i', required=True)
-    # parser.add_argument('--output', '-o',required=True)
-    parser.add_argument('--input','-i', default='./results/performance_analysis_report.json')
-    parser.add_argument('--output', '-o', default='./results/performance_analysis_report.png')
-    args = parser.parse_args()
-    if not os.path.exists(args.input):
-        raise ValueError(f'输入文件不存在:{args.input}')
-    # 读取json数据
-    data = read_json(args.input)
-    
-    # 创建更大的图表
-    fig = plt.figure(figsize=(20, 18))
-    fig.suptitle('Python 性能分析报告', fontsize=20, fontweight='bold')
-    
-    # 创建子图
-    # cProfile 表格
-    ax1 = plt.subplot2grid((4, 2), (0, 0), colspan=1)
-    # cProfile 柱状图
-    ax2 = plt.subplot2grid((4, 2), (0, 1), colspan=1)
-    # 内存使用情况
-    ax3 = plt.subplot2grid((4, 2), (1, 0), colspan=1)
-    # 系统资源监控
-    ax4 = plt.subplot2grid((4, 2), (1, 1), colspan=1)
-    # 网络使用情况
-    ax5 = plt.subplot2grid((4, 2), (2, 0), colspan=1)
-    # 磁盘读写情况
-    ax6 = plt.subplot2grid((4, 2), (2, 1), colspan=1)
-    
-    # 绘制各个子图
-    plot_cprofile_table(ax1, data.get('analysis_results', {}).get('cprofile', {}))
-    plot_cprofile_bar_chart(ax2, data.get('analysis_results', {}).get('cprofile', {}))
-    plot_memory_data(ax3, data.get('analysis_results', {}).get('memory_profile', {}))
-    plot_psutil_data(ax4, data.get('analysis_results', {}).get('psutil', {}))
-    plot_network_data(ax5, data.get('analysis_results', {}).get('psutil', {}))
-    plot_disk_io_data(ax6, data.get('analysis_results', {}).get('psutil', {}))
-    
-    # 调整布局
-    plt.tight_layout()
-    
-    # 保存图像
-    plt.savefig(args.output, dpi=300, bbox_inches='tight')
-    print(f"性能分析图表已保存至: {args.output}")
-
-if __name__ == '__main__':
-    main()

+ 0 - 0
plot.py → plot_offline.py


+ 0 - 2
readme.md

@@ -9,5 +9,3 @@ TODO:
 
 2.增加GPU统计支持
 
-3.启动方式增加动态命令启动
-

+ 7 - 0
test/test_script.py

@@ -26,6 +26,13 @@ def memory_intensive_task():
     return len(big_list)
 
 def main():
+    import argparse
+    parser = argparse.ArgumentParser(description='待测试脚本')
+    parser.add_argument('--input', '-i', type=str, required=True, help='输入')
+    parser.add_argument('--output', '-o', type=str, required=True, help='输出')
+    args = parser.parse_args()
+    print(f"输入参数: {args.input}")
+    print(f"输出参数: {args.output}")
     print("开始执行测试任务...")
     time.sleep(3)
     # 执行各种类型的任务