result_analyzers.py 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. # Copyright Materialize, Inc. and contributors. All rights reserved.
  2. #
  3. # Use of this software is governed by the Business Source License
  4. # included in the LICENSE file at the root of this repository.
  5. #
  6. # As of the Change Date specified in that file, in accordance with
  7. # the Business Source License, use of this software will be governed
  8. # by the Apache License, Version 2.0.
  9. from materialize.scalability.endpoint.endpoint import Endpoint
  10. from materialize.scalability.result.comparison_outcome import ComparisonOutcome
  11. from materialize.scalability.result.result_analyzer import ResultAnalyzer
  12. from materialize.scalability.result.scalability_change import (
  13. Regression,
  14. ScalabilityImprovement,
  15. )
  16. from materialize.scalability.result.workload_result import WorkloadResult
  17. class DefaultResultAnalyzer(ResultAnalyzer):
  18. def __init__(self, max_deviation_as_percent_decimal: float):
  19. self.max_deviation_as_percent_decimal = max_deviation_as_percent_decimal
  20. def perform_comparison_in_workload(
  21. self,
  22. workload_name: str,
  23. baseline_endpoint: Endpoint,
  24. other_endpoint: Endpoint,
  25. regression_baseline_result: WorkloadResult,
  26. other_result: WorkloadResult,
  27. ) -> ComparisonOutcome:
  28. # tps = transactions per seconds (higher is better)
  29. merged_data = regression_baseline_result.df_totals.merge(other_result.df_totals)
  30. tps_per_endpoint_data = merged_data.to_enriched_result_frame(
  31. baseline_endpoint.try_load_version(), other_endpoint.try_load_version()
  32. )
  33. entries_worse_than_threshold = tps_per_endpoint_data.to_filtered_with_threshold(
  34. self.max_deviation_as_percent_decimal,
  35. match_results_better_than_baseline=False,
  36. )
  37. entries_better_than_threshold = (
  38. tps_per_endpoint_data.to_filtered_with_threshold(
  39. self.max_deviation_as_percent_decimal,
  40. match_results_better_than_baseline=True,
  41. )
  42. )
  43. comparison_outcome = ComparisonOutcome()
  44. regressions = entries_worse_than_threshold.to_scalability_change(
  45. Regression,
  46. workload_name,
  47. other_endpoint,
  48. )
  49. improvements = entries_better_than_threshold.to_scalability_change(
  50. ScalabilityImprovement,
  51. workload_name,
  52. other_endpoint,
  53. )
  54. comparison_outcome.append_regressions(
  55. regressions,
  56. improvements,
  57. entries_worse_than_threshold,
  58. entries_better_than_threshold,
  59. )
  60. return comparison_outcome