Skip to content

Commit

Permalink
fix: rename option of ResponseTime (#355)
Browse files Browse the repository at this point in the history
* fix: timeseries histogram option

Signed-off-by: rokamu623 <[email protected]>

* fix: response time stacked bar option name

Signed-off-by: rokamu623 <[email protected]>

* fix: default option

Signed-off-by: rokamu623 <[email protected]>

* fix: doc string and naming

Signed-off-by: rokamu623 <[email protected]>

* fix: syntax in doc string

Signed-off-by: rokamu623 <[email protected]>

* fix: update description of response time

Signed-off-by: rokamu623 <[email protected]>

* fix: minor mistake and flake8

Signed-off-by: rokamu623 <[email protected]>

* fix: drop unvisualize column

Signed-off-by: rokamu623 <[email protected]>

---------

Signed-off-by: rokamu623 <[email protected]>
  • Loading branch information
rokamu623 authored Sep 27, 2023
1 parent c1145ad commit 9c2b674
Show file tree
Hide file tree
Showing 11 changed files with 154 additions and 111 deletions.
2 changes: 1 addition & 1 deletion src/caret_analyze/plot/histogram/histogram_plot_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def create_instance(
supported metrics: [frequency/latency/period/response_time]
case : str, optional
Response time calculation method, used only for response time.
supported case: [best/worst/worst-in-input/all].
supported case: [all/best/worst/worst-with-external-latency].
visualize_lib : VisualizeLibInterface
Instance of VisualizeLibInterface used for visualization.
Expand Down
18 changes: 9 additions & 9 deletions src/caret_analyze/plot/plot_facade.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class Plot:
def create_response_time_stacked_bar_plot(
target_object: Path,
metrics: str = 'latency',
case: str = 'worst'
case: str = 'all'
) -> StackedBarPlot:
"""
Get StackedBarPlot instance.
Expand All @@ -84,8 +84,8 @@ def create_response_time_stacked_bar_plot(
Metrics for stacked bar graph.
supported metrics: [latency]
case : str, optional
Response time calculation method, worst by default.
supported case: [best/worst].
Response time calculation method, all by default.
supported case: [all/best/worst/worst-with-external-latency].
Returns
-------
Expand Down Expand Up @@ -178,7 +178,7 @@ def create_latency_timeseries_plot(
@staticmethod
def create_response_time_timeseries_plot(
*target_objects: Path,
case: str = 'best'
case: str = 'all'
) -> PlotBase:
"""
Get response time timeseries plot instance.
Expand All @@ -189,8 +189,8 @@ def create_response_time_timeseries_plot(
Instances that are the sources of the plotting.
This also accepts multiple inputs by unpacking.
case: str, optional
Response time calculation method, best by default.
supported case: [best/worst/worst-in-input/all].
Response time calculation method, all by default.
supported case: [all/best/worst/worst-with-external-latency].
Returns
-------
Expand Down Expand Up @@ -350,7 +350,7 @@ def create_period_histogram_plot(
@staticmethod
def create_response_time_histogram_plot(
*target_objects: Path,
case: str = 'best',
case: str = 'all',
) -> PlotBase:
"""
Get response time histogram plot instance.
Expand All @@ -361,8 +361,8 @@ def create_response_time_histogram_plot(
Instances that are the sources of the plotting.
This also accepts multiple inputs by unpacking.
case: str, optional
Response time calculation method, best by default.
supported case: [best/worst/worst-in-input/all].
Response time calculation method, all by default.
supported case: [all/best/worst/worst-with-external-latency].
Returns
-------
Expand Down
17 changes: 10 additions & 7 deletions src/caret_analyze/plot/stacked_bar/latency_stacked_bar.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class LatencyStackedBar:
def __init__(
self,
target_objects: Path,
case: str = 'worst',
case: str = 'all',
) -> None:
self._target_objects = target_objects
self._case = case
Expand Down Expand Up @@ -104,14 +104,17 @@ def _get_response_time_record(
response_time = ResponseTime(target_object.to_records(),
columns=target_object.column_names)
# include timestamp of response time (best, worst)
if self._case == 'best':
return response_time.to_best_case_stacked_bar()
if self._case == 'worst-in-input':
return response_time.to_worst_in_input_case_stacked_bar()
if self._case == 'all':
return response_time.to_all_stacked_bar()

return response_time.to_stacked_bar()
elif self._case == 'best':
return response_time.to_best_case_stacked_bar()
elif self._case == 'worst':
return response_time.to_worst_case_stacked_bar()
elif self._case == 'worst-with-external-latency':
return response_time.to_worst_with_external_latency_case_stacked_bar()
else:
raise ValueError('optional argument "case" must be following: \
"all", "best", "worst", "worst-with-external-latency".')

@property
def target_objects(self) -> Path:
Expand Down
2 changes: 1 addition & 1 deletion src/caret_analyze/plot/stacked_bar/stacked_bar_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def __init__(
self,
metrics: LatencyStackedBar,
visualize_lib: VisualizeLibInterface,
case: str = 'worst',
case: str = 'all',
) -> None:
self._metrics = metrics
self._visualize_lib = visualize_lib
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def create_instance(
target_objects: Path,
visualize_lib: VisualizeLibInterface,
metrics: str = 'latency',
case: str = 'worst',
case: str = 'all',
) -> StackedBarPlot:
"""
Create stacked bar class.
Expand All @@ -42,7 +42,7 @@ def create_instance(
visualize_lib : VisualizeLibInterface
Instance of VisualizeLibInterface used for visualization.
case : str
To choose best or worst case response time.
To choose all, best, worst, or worst-with-external-latency case response time.
Returns
-------
Expand Down
14 changes: 9 additions & 5 deletions src/caret_analyze/plot/timeseries/response_time_timeseries.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,17 @@ def to_timeseries_records_list(
response_timeseries_list: list[RecordsInterface] = []
for records in timeseries_records_list:
response = ResponseTime(records)
if self._case == 'best':
if self._case == 'all':
response_timeseries_list.append(response.to_all_records())
elif self._case == 'best':
response_timeseries_list.append(response.to_best_case_records())
elif self._case == 'worst':
response_timeseries_list.append(response.to_worst_case_records())
elif self._case == 'all':
response_timeseries_list.append(response.to_all_records())
elif self._case == 'worst-in-input':
response_timeseries_list.append(response.to_worst_in_input_records())
elif self._case == 'worst-with-external-latency':
response_timeseries_list.append(
response.to_worst_with_external_latency_case_records())
else:
raise ValueError('optional argument "case" must be following: \
"all", "best", "worst", "worst-with-external-latency".')

return response_timeseries_list
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def create_instance(
visualize_lib : VisualizeLibInterface
Instance of VisualizeLibInterface used for visualization.
case : str
Parameter specifying best, worst, worst-in-input, or all.
Parameter specifying all, best, worst, or worst-with-external-latency.
Use to create Response time timeseries graph.
Returns
Expand Down
26 changes: 15 additions & 11 deletions src/caret_analyze/plot/visualize_lib/bokeh/bokeh.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def stacked_bar(
xaxis_type: str,
ywheel_zoom: bool,
full_legends: bool,
case: str, # best or worst
case: str, # all, best, worst or worst-with-external-latency
) -> Figure:
stacked_bar = BokehStackedBar(metrics, xaxis_type, ywheel_zoom, full_legends, case)
return stacked_bar.create_figure()
Expand Down Expand Up @@ -162,7 +162,7 @@ def timeseries(
If True, all legends are drawn
even if the number of legends exceeds the threshold.
case : str
Parameter specifying best, worst, worst-in-input, or all.
Parameter specifying all, best, worst, or worst-with-external-latency.
Use to create Response time timeseries graph.
Expand Down Expand Up @@ -195,7 +195,7 @@ def histogram(
Name of metrics.
"frequency", "latency", "period" or "response_time" can be specified.
case : str
Parameter specifying best, worst, worst-in-input, or all.
Parameter specifying all, best, worst, or worst-with-external-latency.
Use to create Response time histogram graph.
Expand All @@ -220,30 +220,34 @@ def histogram(

data_list: list[list[int]] = []
if data_type == 'response_time':
if case == 'worst':
if case == 'all':
data_list = [
[_ for _ in m.to_worst_case_records().get_column_series(data_type)
[_ for _ in m.to_all_records().get_column_series(data_type)
if _ is not None]
for m in metrics if isinstance(m, ResponseTime)
]
elif case == 'worst-in-input':
elif case == 'best':
data_list = [
[_ for _ in m.to_worst_in_input_records().get_column_series(data_type)
[_ for _ in m.to_best_case_records().get_column_series(data_type)
if _ is not None]
for m in metrics if isinstance(m, ResponseTime)
]
elif case == 'all':
elif case == 'worst':
data_list = [
[_ for _ in m.to_all_records().get_column_series(data_type)
[_ for _ in m.to_worst_case_records().get_column_series(data_type)
if _ is not None]
for m in metrics if isinstance(m, ResponseTime)
]
else:
elif case == 'worst-with-external-latency':
data_list = [
[_ for _ in m.to_best_case_records().get_column_series(data_type)
[_ for _ in
m.to_worst_with_external_latency_case_records().get_column_series(data_type)
if _ is not None]
for m in metrics if isinstance(m, ResponseTime)
]
else:
raise ValueError('optional argument "case" must be following: \
"all", "best", "worst", "worst-with-external-latency".')
else:
data_list = [
[_ for _ in m.to_records().get_column_series(data_type) if _ is not None]
Expand Down
Loading

0 comments on commit 9c2b674

Please sign in to comment.