data_analysis_3.py 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. def develop_stats_plot(delta:str):
  2. with open(os.path.join(folder_use, get_file_name_json(False)), 'r') as file:
  3. value_delta = [f.get(delta, -1) for f in json.load(file)]
  4. value_plot_mean = plt.scatter(
  5. value_x,
  6. [
  7. statistics.mean(value_delta[:i])
  8. for i in value_x
  9. ]
  10. )
  11. if delta == 'delta_full':
  12. k = "Between send and inserting values"
  13. elif delta == 'delta_send':
  14. k = "Between sent and receive of the consumer"
  15. elif delta == 'delta_proccessed':
  16. k = "Between receive of the consumer and insert"
  17. plt.title(f'{k}: mean')
  18. plt.ylabel("Seconds")
  19. plt.xlabel("Number of elements")
  20. plt.close()
  21. value_plot_var = plt.scatter(
  22. value_x,
  23. [
  24. statistics.variance(value_delta[:i])
  25. for i in value_x
  26. ]
  27. )
  28. plt.title(f'{k}: variance')
  29. plt.ylabel("Seconds")
  30. plt.xlabel("Number of elements")
  31. plt.close()
  32. value_plot_dev = plt.scatter(
  33. value_x,
  34. [
  35. statistics.stdev(value_delta[:i])
  36. for i in value_x
  37. ]
  38. )
  39. plt.title(f'{k}: deviation')
  40. plt.ylabel("Seconds")
  41. plt.xlabel("Number of elements")
  42. plt.close()
  43. value_plot_mean.figure.savefig(value_selected_file_plot(delta, 'mean'))
  44. value_plot_var.figure.savefig(value_selected_file_plot(delta, 'variance'))
  45. value_plot_dev.figure.savefig(value_selected_file_plot(delta, 'deviation'))