Skip to content
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

Merged
merged 2 commits into from
Aug 27, 2024

Conversation

Thuwzq
Copy link
Contributor

@Thuwzq Thuwzq commented Aug 26, 2024

Add a python script to observe the relationship between stream offset and time

@codecov-commenter
Copy link

codecov-commenter commented Aug 26, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.22%. Comparing base (9678772) to head (7cd169b).

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.
📢 Have feedback on the report? Share it here.


# 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')
Copy link
Collaborator

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
Copy link
Collaborator

@iyangsj iyangsj Aug 27, 2024

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()

Copy link
Collaborator

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 函数中

continue

connection_stream_frame_match = connection_stream_pattern.search(line)
if connection_stream_frame_match:
Copy link
Collaborator

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

...

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:

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

去除 line 28 多余的空行

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'))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

X 轴显示的时间,增加毫秒,避免短流(例如 1s 内)无法显示有效时间信息

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()
Copy link
Collaborator

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__':

Copy link
Collaborator

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

Copy link
Collaborator

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.


# 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')
Copy link
Collaborator

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 级别日志,否则用户可能发现无法正确绘图

@iyangsj iyangsj merged commit 9766b2d into Tencent:develop Aug 27, 2024
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants