From 7474ddbaac4f97ac78795dc1efa2c97894c3654a Mon Sep 17 00:00:00 2001
From: SengokuCola <1026294844@qq.com>
Date: Mon, 23 Jun 2025 00:34:18 +0800
Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9A=E4=BF=AE=E5=A4=8Dhfc=E8=AE=B0?=
=?UTF-8?q?=E5=BD=95=E5=99=A8?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/chat/focus_chat/hfc_performance_logger.py | 2 +-
src/chat/utils/statistic.py | 30 +++++++++----------
2 files changed, 16 insertions(+), 16 deletions(-)
diff --git a/src/chat/focus_chat/hfc_performance_logger.py b/src/chat/focus_chat/hfc_performance_logger.py
index a540c1d76..c7b9d7ab5 100644
--- a/src/chat/focus_chat/hfc_performance_logger.py
+++ b/src/chat/focus_chat/hfc_performance_logger.py
@@ -1,6 +1,6 @@
import json
from datetime import datetime
-from typing import Dict, List, Any
+from typing import Dict, Any
from pathlib import Path
from src.common.logger import get_logger
diff --git a/src/chat/utils/statistic.py b/src/chat/utils/statistic.py
index 63715f5d7..abf58c8f7 100644
--- a/src/chat/utils/statistic.py
+++ b/src/chat/utils/statistic.py
@@ -598,7 +598,7 @@ class StatisticOutputTask(AsyncTask):
"""
计算Focus统计的平均值
"""
- for period_key, stat in stats.items():
+ for _period_key, stat in stats.items():
# 计算全局阶段平均时间
for stage, times in stat[FOCUS_AVG_TIMES_BY_STAGE].items():
if times:
@@ -944,27 +944,27 @@ class StatisticOutputTask(AsyncTask):
)
# Focus统计数据
- focus_action_rows = ""
- focus_chat_rows = ""
- focus_stage_rows = ""
- focus_action_stage_rows = ""
+ # focus_action_rows = ""
+ # focus_chat_rows = ""
+ # focus_stage_rows = ""
+ # focus_action_stage_rows = ""
if stat_data.get(FOCUS_TOTAL_CYCLES, 0) > 0:
# Action类型统计
total_actions = sum(stat_data[FOCUS_ACTION_RATIOS].values()) if stat_data[FOCUS_ACTION_RATIOS] else 0
- focus_action_rows = "\n".join([
+ _focus_action_rows = "\n".join([
f"
| {action_type} | {count} | {(count/total_actions*100):.1f}% |
"
for action_type, count in sorted(stat_data[FOCUS_ACTION_RATIOS].items())
])
# 按聊天流统计
- focus_chat_rows = "\n".join([
+ _focus_chat_rows = "\n".join([
f"| {self.name_mapping.get(chat_id, (chat_id, 0))[0]} | {count} | {stat_data[FOCUS_TOTAL_TIME_BY_CHAT].get(chat_id, 0):.2f}秒 |
"
for chat_id, count in sorted(stat_data[FOCUS_CYCLE_CNT_BY_CHAT].items(), key=lambda x: x[1], reverse=True)
])
# 全局阶段时间统计
- focus_stage_rows = "\n".join([
+ _focus_stage_rows = "\n".join([
f"| {stage} | {avg_time:.3f}秒 |
"
for stage, avg_time in sorted(stat_data[FOCUS_AVG_TIMES_BY_STAGE].items())
])
@@ -975,7 +975,7 @@ class StatisticOutputTask(AsyncTask):
for stage, avg_time in stage_times.items():
focus_action_stage_items.append((action_type, stage, avg_time))
- focus_action_stage_rows = "\n".join([
+ _focus_action_stage_rows = "\n".join([
f"| {action_type} | {stage} | {avg_time:.3f}秒 |
"
for action_type, stage, avg_time in sorted(focus_action_stage_items)
])
@@ -1236,7 +1236,7 @@ class StatisticOutputTask(AsyncTask):
for stage in basic_stages:
# 检查是否有任何聊天流在这个阶段有数据
stage_exists = False
- for chat_id, stage_times in stat_data[FOCUS_AVG_TIMES_BY_CHAT_ACTION].items():
+ for _chat_id, stage_times in stat_data[FOCUS_AVG_TIMES_BY_CHAT_ACTION].items():
if stage in stage_times:
stage_exists = True
break
@@ -1274,7 +1274,7 @@ class StatisticOutputTask(AsyncTask):
if avg_exec_time > 0:
row_cells.append(f"{avg_exec_time:.3f}秒 | ")
else:
- row_cells.append(f"- | ")
+ row_cells.append("- | ")
chat_rows.append(f"{''.join(row_cells)}
")
@@ -1315,7 +1315,7 @@ class StatisticOutputTask(AsyncTask):
if count > 0:
row_cells.append(f"{count} ({ratio:.1f}%) | ")
else:
- row_cells.append(f"- (0%) | ")
+ row_cells.append("- (0%) | ")
chat_ratio_rows.append(f"{''.join(row_cells)}
")
@@ -1628,7 +1628,7 @@ class StatisticOutputTask(AsyncTask):
exec_time = version_exec_times[version][action_type]
row_cells.append(f"{exec_time:.3f}秒 | ")
else:
- row_cells.append(f"- | ")
+ row_cells.append("- | ")
version_stage_rows.append(f"{''.join(row_cells)}
")
@@ -1922,9 +1922,9 @@ class StatisticOutputTask(AsyncTask):
if stage not in focus_time_by_stage:
focus_time_by_stage[stage] = [0] * len(time_points)
focus_time_by_stage[stage][interval_index] += time_val
- except Exception as e:
+ except Exception:
continue
- except Exception as e:
+ except Exception:
continue
return {