MCPcopy Create free account
hub / github.com/ARM-software/astc-encoder / run_pass

Function run_pass

Test/astc_profile_valgrind.py:100–175  ·  view source on GitHub ↗

Run Valgrind on a single binary. Args: image: The path of the image to compress. encoder: The encoder variant to use. block_size: The block size to use. quality: The compression quality to use. show_cli: Show command line wrapper tool cost in the pro

(image: str, encoder: str,
             block_size: str, quality: str, show_cli: bool)

Source from the content-addressed store, hash-verified

98
99
100def run_pass(image: str, encoder: str,
101 block_size: str, quality: str, show_cli: bool) -> None:
102 '''
103 Run Valgrind on a single binary.
104
105 Args:
106 image: The path of the image to compress.
107 encoder: The encoder variant to use.
108 block_size: The block size to use.
109 quality: The compression quality to use.
110 show_cli: Show command line wrapper tool cost in the profile.
111
112 Raise:
113 CalledProcessException: Any subprocess failed.
114 '''
115 binary = f'./bin/astcenc-{encoder}'
116 quality_log = quality.replace('-', '')
117
118 # Run Valgrind
119 args = [
120 'valgrind',
121 '--tool=callgrind',
122 '--callgrind-out-file=callgrind.txt',
123 binary, '-ch', image, '/dev/null', block_size, quality, '-j', '1'
124 ]
125
126 sp.run(args, check=True)
127
128 # Run callgrind analysis
129 args = [
130 'callgrind_annotate',
131 'callgrind.txt'
132 ]
133
134 ret = sp.run(args, stdout=sp.PIPE, check=True, encoding='utf-8')
135 lines = ret.stdout.splitlines()
136
137 # Write raw annotated callgrind log
138 report = '\n'.join(lines)
139 with open(f'perf_{quality_log}_cga.txt', 'w', encoding='utf=8') as handle:
140 handle.write(report)
141
142 # Write our text summary of the top functions
143 report = rank_hot_functions(lines)
144 with open(f'perf_{quality_log}.txt', 'w', encoding='utf=8') as handle:
145 handle.write(report)
146
147 # Write the visual call graph
148 entry_func = 'main'
149 if not show_cli:
150 entry_func = 'compress_block(' \
151 'astcenc_contexti const&, ' \
152 'image_block const&, ' \
153 'unsigned char*, ' \
154 'compression_working_buffers&)'
155
156 args = [
157 'gprof2dot',

Callers 1

mainFunction · 0.85

Calls 1

rank_hot_functionsFunction · 0.85

Tested by

no test coverage detected