[latency] filesrc latency compenstation
:Release Notes: There are maybe an error in latency measurement related to filesrc module work :Detailed Notes: - :Testing Performed: - :QA Notes: - :Issues Addressed: -
This commit is contained in:
parent
8b9190bb86
commit
420e42daeb
@ -2,11 +2,69 @@ import pandas as pd
|
||||
import matplotlib.pyplot as plt
|
||||
import numpy as np
|
||||
import os
|
||||
import argparse
|
||||
import logging
|
||||
|
||||
# Configure logging to show informational messages
|
||||
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
|
||||
|
||||
prefixImage = 'histograms/'
|
||||
|
||||
def parse_args():
|
||||
parser = argparse.ArgumentParser(prog=__file__)
|
||||
parser.add_argument('-c', '--compensate', action="store_true")
|
||||
return parser.parse_args()
|
||||
|
||||
cmd_args = None
|
||||
def get_args():
|
||||
global cmd_args
|
||||
if cmd_args is None:
|
||||
cmd_args = parse_args()
|
||||
return cmd_args
|
||||
|
||||
def plot_latency_data(df):
|
||||
def create_labels(df):
|
||||
"""Combines MultiIndex levels (L0-L3) into a single string for notes."""
|
||||
labels = {}
|
||||
for i, index in enumerate(df.index):
|
||||
# Format: L#:value | L#:value | ...
|
||||
label_parts = [f"L{j}:{val}" for j, val in enumerate(index)]
|
||||
labels[i + 1] = " | ".join(label_parts)
|
||||
return labels
|
||||
|
||||
df = df.head(10)
|
||||
encoder_name = df.index.get_level_values(0)[0]
|
||||
max_notes = create_labels(df)
|
||||
|
||||
bar_width = 0.25
|
||||
num_configs = len(df)
|
||||
r1 = np.arange(num_configs)
|
||||
r2 = [x + bar_width for x in r1]
|
||||
r3 = [x + bar_width for x in r2]
|
||||
fig = plt.figure(figsize=(10, 6), dpi=300)
|
||||
# Create the bars
|
||||
plt.bar(r1, df['max'], color='red', width=bar_width, edgecolor='grey', label='Max Latency')
|
||||
plt.bar(r2, df['avg'], color='blue', width=bar_width, edgecolor='grey', label='Avg Latency')
|
||||
plt.bar(r3, df['median'], color='green', width=bar_width, edgecolor='grey', label='Median Latency')
|
||||
|
||||
# Add labels and ticks
|
||||
plt.xlabel('Индекс конфигурации', fontweight='bold')
|
||||
plt.ylabel('Общая задержка [мс]', fontweight='bold')
|
||||
plt.xticks([r + bar_width for r in range(num_configs)], [str(i + 1) for i in range(num_configs)])
|
||||
plt.title(f'Сравнение производительности {num_configs} лучших конфигураций по задержке для {encoder_name}')
|
||||
plt.legend()
|
||||
plt.grid(axis='y', linestyle='--', alpha=0.6)
|
||||
|
||||
plt.tight_layout()
|
||||
plt.savefig(prefixImage + f'combined_top_configurations_plot_{encoder_name}.png')
|
||||
plt.close()
|
||||
|
||||
# Output Notes (for user interpretation)
|
||||
print("\n--- Notes for Plot (X-Axis Index to Configuration) ---")
|
||||
for index, note in max_notes.items():
|
||||
print(f"Index {index}: {note}")
|
||||
|
||||
|
||||
def analyze_latency_data(csv_path: str):
|
||||
"""
|
||||
Analyzes latency data to find the top 10 components (rows) contributing most
|
||||
@ -30,7 +88,12 @@ def analyze_latency_data(csv_path: str):
|
||||
|
||||
#calculate summary along the rows
|
||||
sumDf = df.sum()
|
||||
print(sumDf.info())
|
||||
if get_args().compensate == True:
|
||||
logging.info("Filesrc latency compensation is ON")
|
||||
filesrcData = df.loc["filesrc0"]
|
||||
sumDf -= filesrcData
|
||||
print(sumDf.head())
|
||||
# return
|
||||
|
||||
df_summary = sumDf.unstack(level=-1) # or level='Metric' if names are set
|
||||
|
||||
@ -61,52 +124,12 @@ def analyze_latency_data(csv_path: str):
|
||||
df_common_top_performers = df_summary.loc[common_indices]
|
||||
print(df_common_top_performers.head())
|
||||
|
||||
def create_labels(df):
|
||||
"""Combines MultiIndex levels (L0-L3) into a single string for notes."""
|
||||
labels = {}
|
||||
for i, index in enumerate(df.index):
|
||||
# Format: L#:value | L#:value | ...
|
||||
label_parts = [f"L{j}:{val}" for j, val in enumerate(index)]
|
||||
labels[i + 1] = " | ".join(label_parts)
|
||||
return labels
|
||||
|
||||
df_common_top_performers =df_common_top_performers.head(10)
|
||||
encoder_name = df_common_top_performers.index.get_level_values(0)[0]
|
||||
max_notes = create_labels(df_common_top_performers)
|
||||
|
||||
bar_width = 0.25
|
||||
num_configs = len(df_common_top_performers)
|
||||
r1 = np.arange(num_configs)
|
||||
r2 = [x + bar_width for x in r1]
|
||||
r3 = [x + bar_width for x in r2]
|
||||
fig = plt.figure(figsize=(10, 6), dpi=300)
|
||||
# Create the bars
|
||||
plt.bar(r1, df_common_top_performers['max'], color='red', width=bar_width, edgecolor='grey', label='Max Latency')
|
||||
plt.bar(r2, df_common_top_performers['avg'], color='blue', width=bar_width, edgecolor='grey', label='Avg Latency')
|
||||
plt.bar(r3, df_common_top_performers['median'], color='green', width=bar_width, edgecolor='grey', label='Median Latency')
|
||||
|
||||
# Add labels and ticks
|
||||
plt.xlabel('Индекс конфигурации', fontweight='bold')
|
||||
plt.ylabel('Общая задержка [мс]', fontweight='bold')
|
||||
plt.xticks([r + bar_width for r in range(num_configs)], [str(i + 1) for i in range(num_configs)])
|
||||
plt.title(f'Сравнение производительности {num_configs} лучших конфигураций по задержке для {encoder_name}')
|
||||
plt.legend()
|
||||
plt.grid(axis='y', linestyle='--', alpha=0.6)
|
||||
|
||||
plt.tight_layout()
|
||||
plt.savefig(f'combined_top_configurations_plot_{encoder_name}.png')
|
||||
plt.close()
|
||||
|
||||
# Output Notes (for user interpretation)
|
||||
print("\n--- Notes for MAX Plot (X-Axis Index to Configuration) ---")
|
||||
for index, note in max_notes.items():
|
||||
print(f"Index {index}: {note}")
|
||||
|
||||
# Sort
|
||||
plot_latency_data(df_common_top_performers)
|
||||
return
|
||||
|
||||
if __name__ == '__main__':
|
||||
parse_args()
|
||||
# Set the path to your CSV file here.
|
||||
csv_filename = 'results/latencyDataframenvv4l2h264enc.csv'
|
||||
csv_filename = 'sample/latencyDataframenvh264enc.csv'
|
||||
analyze_latency_data(csv_filename)
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user