|
1 | 1 | # BSD 3-Clause License |
2 | 2 | # |
3 | | -# Copyright (c) 2021., Redis Labs Modules |
| 3 | +# Copyright (c) 2022., Redis Labs Modules |
4 | 4 | # All rights reserved. |
5 | 5 | # |
| 6 | + |
| 7 | +# BSD 3-Clause License |
| 8 | +# |
| 9 | +# |
6 | 10 | import logging |
7 | 11 | import platform |
8 | 12 |
|
9 | 13 | from cpuinfo import get_cpu_info |
10 | | -from pytablewriter import MarkdownTableWriter |
11 | 14 |
|
12 | 15 | from redisbench_admin.profilers.perf import Perf |
13 | 16 | from redisbench_admin.profilers.vtune import Vtune |
14 | 17 | from redisbench_admin.run.args import PROFILE_FREQ, MAX_PROFILERS_PER_TYPE |
15 | | - |
16 | 18 | from redisbench_admin.run.s3 import get_test_s3_bucket_path |
17 | 19 | from redisbench_admin.utils.utils import upload_artifacts_to_s3 |
18 | 20 |
|
19 | 21 |
|
20 | | -def local_profilers_print_artifacts_table(profilers_artifacts_matrix): |
21 | | - logging.info("Printing profiler generated artifacts") |
22 | | - test_cases = [] |
23 | | - profilers = [] |
24 | | - use_local_file = True |
25 | | - table_name = "Profiler artifacts" |
26 | | - for row in profilers_artifacts_matrix: |
27 | | - test_case = row[0] |
28 | | - profiler = row[1] |
29 | | - artifact = row[2] |
30 | | - local_file = row[3] |
31 | | - s3_link = row[4] |
32 | | - if s3_link is not None: |
33 | | - if len(s3_link) > 0: |
34 | | - use_local_file = False |
35 | | - |
36 | | - if test_case not in test_cases: |
37 | | - test_cases.append(test_case) |
38 | | - if profiler not in profilers: |
39 | | - profilers.append(profiler) |
40 | | - |
41 | | - # We only need to print the testcase if there are more than one |
42 | | - use_test_cases_row = True |
43 | | - |
44 | | - if len(test_cases) == 1: |
45 | | - use_test_cases_row = False |
46 | | - test_case = test_cases[0] |
47 | | - table_name = "{} for testcase {}".format(table_name, test_case) |
48 | | - |
49 | | - # We only need to print the profiler type if there are more than one |
50 | | - use_profilers_row = True |
51 | | - if len(profilers) == 1: |
52 | | - use_profilers_row = False |
53 | | - profiler = test_cases[0] |
54 | | - table_name = "{}. Used profiler {}".format(table_name, profiler) |
55 | | - |
56 | | - headers = [] |
57 | | - if use_test_cases_row: |
58 | | - headers.append("Test Case") |
59 | | - |
60 | | - if use_profilers_row: |
61 | | - headers.append("Profiler") |
62 | | - |
63 | | - headers.append("Artifact") |
64 | | - if use_local_file: |
65 | | - headers.append("Local file") |
66 | | - else: |
67 | | - headers.append("s3 link") |
68 | | - |
69 | | - profilers_final_matrix = [] |
70 | | - for row in profilers_artifacts_matrix: |
71 | | - test_case = row[0] |
72 | | - profiler = row[1] |
73 | | - artifact = row[2] |
74 | | - local_file = "{} ".format(row[3]) |
75 | | - s3_link = "{} ".format(row[4]) |
76 | | - |
77 | | - final_row = [] |
78 | | - if use_test_cases_row: |
79 | | - final_row.append(test_case) |
80 | | - |
81 | | - if use_profilers_row: |
82 | | - final_row.append(profiler) |
83 | | - |
84 | | - final_row.append(artifact) |
85 | | - if use_local_file: |
86 | | - final_row.append(local_file) |
87 | | - else: |
88 | | - final_row.append(s3_link) |
89 | | - profilers_final_matrix.append(final_row) |
90 | | - |
91 | | - writer = MarkdownTableWriter( |
92 | | - table_name=table_name, |
93 | | - headers=headers, |
94 | | - value_matrix=profilers_final_matrix, |
95 | | - ) |
96 | | - writer.write_table() |
97 | | - |
98 | | - |
99 | | -def get_profilers_rts_key_prefix(triggering_env, tf_github_org, tf_github_repo): |
100 | | - zset_name = "ci.benchmarks.redis.com/{triggering_env}/{github_org}/{github_repo}:profiles".format( |
101 | | - triggering_env=triggering_env, |
102 | | - github_org=tf_github_org, |
103 | | - github_repo=tf_github_repo, |
104 | | - ) |
105 | | - return zset_name |
106 | | - |
107 | | - |
108 | 22 | def profilers_stop_if_required( |
109 | 23 | args, |
110 | 24 | benchmark_duration_seconds, |
|
0 commit comments