scalability_change.py 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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 __future__ import annotations
  10. from materialize.scalability.endpoint.endpoint import Endpoint
  11. class ScalabilityChange:
  12. def __init__(
  13. self,
  14. workload_name: str,
  15. concurrency: int,
  16. count: int,
  17. tps: float,
  18. tps_baseline: float,
  19. tps_diff: float,
  20. tps_diff_percent: float,
  21. endpoint: Endpoint,
  22. ):
  23. self.workload_name = workload_name
  24. self.concurrency = concurrency
  25. self.count = count
  26. self.tps = tps
  27. self.tps_baseline = tps_baseline
  28. self.tps_diff = tps_diff
  29. self.tps_diff_percent = tps_diff_percent
  30. self.endpoint = endpoint
  31. self._validate_data()
  32. def _validate_data(self) -> None:
  33. pass
  34. def get_type(self) -> str:
  35. raise RuntimeError("Not implemented")
  36. def __str__(self) -> str:
  37. return (
  38. f"{self.get_type()} in workload '{self.workload_name}' at concurrency {self.concurrency} with {self.endpoint}:"
  39. f" {round(self.tps, 2)} tps vs. {round(self.tps_baseline, 2)} tps"
  40. f" ({round(self.tps_diff, 2)} tps; {round(100 * self.tps_diff_percent, 2)}%)"
  41. )
  42. class Regression(ScalabilityChange):
  43. def _validate_data(self) -> None:
  44. assert self.tps_diff < 0, "Not a regression!"
  45. def get_type(self) -> str:
  46. return "Regression"
  47. class ScalabilityImprovement(ScalabilityChange):
  48. def _validate_data(self) -> None:
  49. assert self.tps_diff > 0, "Not an improvement!"
  50. def get_type(self) -> str:
  51. return "Scalability improvement"