CodexBar 是一个 macOS 菜单栏应用,用于查看本机 Codex 账号状态、额度、Token 用量、详细统计信息
Swift appkitcodexcodex-clideveloper-toolsmacosmacos-appmenu-bar-appopenai-codexproductivityswiftswiftuiusage-tracker
chore: 调整性能采集预设并优化报告展示
Bob436fbd0096fa
diff --git a/Scripts/performance/README.md b/Scripts/performance/README.mdindex 5bd7e82..1293a36 100644--- a/Scripts/performance/README.md+++ b/Scripts/performance/README.md@@ -33,15 +33,17 @@ python3 -B Scripts/performance/run.py \| 预设 | 预热 | CPU 采集 | 资源观察 | 后续观察 | 累计采集 ||---|---:|---:|---:|---:|---:|-| `quick` | 5 秒 | 2 × 20 秒 | 60 秒 | 20 秒 | 2 分钟 |-| `standard` | 20 秒 | 3 × 60 秒 | 300 秒 | 60 秒 | 9 分钟 |-| `extended` | 30 秒 | 3 × 120 秒 | 900 秒 | 120 秒 | 23 分钟 |+| `quick` | 5 秒 | 2 × 30 秒 | 90 秒 | 30 秒 | 3 分钟 |+| `standard` | 20 秒 | 4 × 60 秒 | 300 秒 | 60 秒 | 10 分钟 |+| `extended` | 30 秒 | 5 × 120 秒 | 900 秒 | 300 秒 | 30 分钟 |- `quick`:检查采集流程,快速观察操作时的资源变化- `standard`:日常性能评估,观察重复采样与后台活动- `extended`:观察更长时间的内存变化和周期性任务-实际运行时间还包括 Instruments 初始化、保存和导出。`cpu-*` 阶段使用 `Time Profiler + Activity Monitor`,同时采集调用栈、资源指标和 Hangs;`soak`、`settle` 阶段使用 `Activity Monitor` 继续观察资源变化。+累计采集不含预热时间。实际运行时间还包括 Instruments 初始化、保存和导出。`cpu-*` 阶段使用 `Time Profiler + Activity Monitor`,同时采集调用栈、资源指标和 Hangs;`soak`、`settle` 阶段使用 `Activity Monitor` 继续观察资源变化。++后续观察阶段不会自动停止工作负载。若要观察操作后的恢复情况,需要手动停止操作并记录时间。## 组织测试场景@@ -115,6 +117,8 @@ python3 -B Scripts/performance/run.py \脚本核对 App 的 bundle ID、系统、芯片、架构、核心数、内存容量、电源来源、Instruments、场景说明、预设、预算、数据格式和阶段计划。两次采集均完整且上述条件一致时,报告展示各阶段平均 CPU 差值和 footprint 中位数差值;条件不匹配时列出差异字段。App 版本可以不同。+预设的采集轮次或时长调整后,需要按新配置重新采集基线。旧结果仍可打开和重新生成报告,但与新阶段计划比较时会标记为条件不匹配。+## 输出文件与重新生成报告| 文件 | 内容 |diff --git a/Scripts/performance/report.html b/Scripts/performance/report.htmlindex 61e622e..1fac5d2 100644--- a/Scripts/performance/report.html+++ b/Scripts/performance/report.html@@ -370,6 +370,13 @@font-weight: 550;}+ .environment-panel th:first-child,+ .environment-panel td:first-child {+ width: 140px;+ min-width: 140px;+ white-space: nowrap;+ }+tr:hover td {background: var(--soft);}@@ -1204,7 +1211,7 @@</div>@@RECORDS@@<div class="two section">- <article class="panel">+ <article class="panel environment-panel"><h3>运行环境</h3>@@METADATA@@</article>diff --git a/Scripts/performance/report.py b/Scripts/performance/report.pyindex 31e0379..a75155c 100644--- a/Scripts/performance/report.py+++ b/Scripts/performance/report.py@@ -254,7 +254,6 @@ def write_report(data, destination):thermal += '</div>'metadata = [["App", target.get("name", "N/A")], ["Bundle ID", target.get("bundle_id", "N/A")],["版本 / 构建", f'{target.get("version", "N/A")} / {target.get("build", "N/A")}'],- ["主进程 PID", target.get("identity", {}).get("pid", "N/A")],["macOS / 架构", f'{env.get("os", "N/A")} / {env.get("arch", "N/A")}'],["芯片 / 逻辑核心", f'{env.get("chip", "N/A")} / {env.get("cores", "N/A")}'],["内存", number(int(env["memory_bytes"]) / 2 ** 30, 0, " GiB") if env.get("memory_bytes") else "N/A"],diff --git a/Scripts/performance/run.py b/Scripts/performance/run.pyindex acf9a32..21e5911 100644--- a/Scripts/performance/run.py+++ b/Scripts/performance/run.py@@ -25,10 +25,19 @@ from report import write_reportVERSION = "1"ROOT = Path(__file__).resolve().parents[2]-SCHEMAS = ("activity-monitor-process-live", "time-profile", "potential-hangs", "hang-risks",- "device-thermal-state-intervals", "activity-monitor-system")-PRESETS = {"quick": (5, 20, 2, 60, 20), "standard": (20, 60, 3, 300, 60),- "extended": (30, 120, 3, 900, 120)}+SCHEMAS = (+ "activity-monitor-process-live",+ "time-profile",+ "potential-hangs",+ "hang-risks",+ "device-thermal-state-intervals",+ "activity-monitor-system"+)+PRESETS = {+ "quick": (5, 30, 2, 90, 30),+ "standard": (20, 60, 4, 300, 60),+ "extended": (30, 120, 5, 900, 300)+}def now():@@ -88,7 +97,7 @@ def inspect_target(app, pid):for stream in (entitlements.stdout, entitlements.stderr):start = stream.find(b"<?xml")end = stream.find(b"</plist>")- if start >= 0 and end >= start:+ if 0 <= start <= end:ent = plistlib.loads(stream[start:end + len(b"</plist>")])breakuuids = optional(["/usr/bin/xcrun", "dwarfdump", "--uuid", str(executable)])