-
Notifications
You must be signed in to change notification settings - Fork 98
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a python script to observe the relationship between stream offset and time #375
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop #375 +/- ##
========================================
Coverage 95.22% 95.22%
========================================
Files 50 50
Lines 33941 33941
========================================
+ Hits 32319 32321 +2
+ Misses 1622 1620 -2 ☔ View full report in Codecov by Sentry. |
tools/script/streamoffset_time.py
Outdated
|
||
# Set up the command line argument parser | ||
parser = argparse.ArgumentParser(description='Analyze TQUIC logs to get the relationship between stream offset and time.') | ||
parser.add_argument('log_file', type=str, help='Path to the TQUIC log file') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
以上三个参数,增加 required=true 属性,要求必须指定参数,否则会报错并输出帮助信息
@@ -0,0 +1,63 @@ | |||
#!/usr/bin/env python3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
使用格式化工具black格式化代码:
python3 -m black <source_dir>
注:安装方式
pip install black --break-system-packages
parser.add_argument('connection_trace_id', type=str, help='Connection trace id, eg. SERVER-c6d45bc005585f42') | ||
parser.add_argument('stream_id', type=int, help='Stream id, eg. 0') | ||
args = parser.parse_args() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line 9~ line14 移动到line60 main 函数中
tools/script/streamoffset_time.py
Outdated
continue | ||
|
||
connection_stream_frame_match = connection_stream_pattern.search(line) | ||
if connection_stream_frame_match: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
减少不必要的缩进
if not connection_stream_frame_match
continue
...
tools/script/streamoffset_time.py
Outdated
connection_stream_pattern = re.compile(r'{} sent packet OneRTT.*?STREAM id={} off=(\d+) len=\d+ fin=(?:true|false)'.format(cid, stream_id)) | ||
|
||
for line in log_data: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
去除 line 28 多余的空行
tools/script/streamoffset_time.py
Outdated
plt.xlabel('Time') | ||
plt.ylabel('Stream Offset') | ||
plt.title(f'Stream {stream_id} Offset by Time in Connection {cid}') | ||
plt.gca().xaxis.set_major_formatter(plt.matplotlib.dates.DateFormatter('%H:%M:%S')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
X 轴显示的时间,增加毫秒,避免短流(例如 1s 内)无法显示有效时间信息
tools/script/streamoffset_time.py
Outdated
plt.ylabel('Stream Offset') | ||
plt.title(f'Stream {stream_id} Offset by Time in Connection {cid}') | ||
plt.gca().xaxis.set_major_formatter(plt.matplotlib.dates.DateFormatter('%H:%M:%S')) | ||
#plt.show() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
清理 line56 无用代码
plt.savefig(output_file_name) | ||
|
||
if __name__ == '__main__': | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
去除 line 60 无用空行
@@ -0,0 +1,63 @@ | |||
#!/usr/bin/env python3 | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
增加如下文件说明,前后各空一行
# This tool is used to analyze TQUIC debug logs and produce a time-offset figure
# for the specified QUIC stream.
tools/script/streamoffset_time.py
Outdated
|
||
# Set up the command line argument parser | ||
parser = argparse.ArgumentParser(description='Analyze TQUIC logs to get the relationship between stream offset and time.') | ||
parser.add_argument('log_file', type=str, help='Path to the TQUIC log file') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
‘Path to the TQUIC log file’ --> 'Path to the TQUIC debug log file'
提示明确说明是 debug 级别日志,否则用户可能发现无法正确绘图
Add a python script to observe the relationship between stream offset and time