|
15 | 15 | # limitations under the License.
|
16 | 16 |
|
17 | 17 | import argparse
|
| 18 | +import csv |
18 | 19 | import glob
|
| 20 | +import math |
19 | 21 | import multiprocessing
|
20 | 22 | import os
|
| 23 | +import pathlib |
21 | 24 | import shutil
|
22 | 25 | import subprocess
|
23 | 26 | import sys
|
@@ -71,27 +74,48 @@ def _build(output_dir):
|
71 | 74 | subprocess.check_call(['git', 'checkout', where_am_i])
|
72 | 75 | subprocess.check_call(['git', 'submodule', 'update'])
|
73 | 76 |
|
74 |
| -subprocess.check_call('make -j%d' % args.jobs, |
75 |
| - shell=True, |
76 |
| - cwd='third_party/bloaty') |
| 77 | +pathlib.Path('bloaty-build').mkdir(exist_ok=True) |
| 78 | +subprocess.check_call( |
| 79 | + ['cmake', '-G', 'Unix Makefiles', '../third_party/bloaty'], |
| 80 | + cwd='bloaty-build') |
| 81 | +subprocess.check_call('make -j%d' % args.jobs, shell=True, cwd='bloaty-build') |
77 | 82 |
|
78 | 83 | text = ''
|
| 84 | +diff_size = 0 |
79 | 85 | for lib in LIBS:
|
80 | 86 | text += '****************************************************************\n\n'
|
81 | 87 | text += lib + '\n\n'
|
82 | 88 | old_version = glob.glob('bloat_diff_old/%s' % lib)
|
83 | 89 | new_version = glob.glob('bloat_diff_new/%s' % lib)
|
84 | 90 | assert len(new_version) == 1
|
85 |
| - cmd = 'third_party/bloaty/bloaty -d compileunits,symbols' |
| 91 | + cmd = 'bloaty-build/bloaty -d compileunits,symbols' |
86 | 92 | if old_version:
|
87 | 93 | assert len(old_version) == 1
|
88 | 94 | text += subprocess.check_output('%s %s -- %s' %
|
89 | 95 | (cmd, new_version[0], old_version[0]),
|
90 | 96 | shell=True).decode()
|
| 97 | + for filename in [old_version, new_version]: |
| 98 | + subprocess.check_call('strip %s' % filename[0], shell=True) |
| 99 | + sections = [ |
| 100 | + x for x in csv.reader( |
| 101 | + subprocess.check_output('bloaty-build/bloaty --csv %s -- %s' % |
| 102 | + (old_version[0], new_version[0]), |
| 103 | + shell=True).decode().splitlines()) |
| 104 | + ] |
| 105 | + print(sections) |
| 106 | + for section in sections[1:]: |
| 107 | + diff_size += int(section[2]) |
91 | 108 | else:
|
92 | 109 | text += subprocess.check_output('%s %s' % (cmd, new_version[0]),
|
93 | 110 | shell=True).decode()
|
94 | 111 | text += '\n\n'
|
95 | 112 |
|
| 113 | +severity = int( |
| 114 | + math.copysign(max(0, math.log(abs(diff_size) / 1000, 10), |
| 115 | + diff_size))) if diff_size != 0 else 0 |
| 116 | + |
| 117 | +print("SEVERITY: %d" % severity) |
| 118 | + |
96 | 119 | print(text)
|
97 | 120 | check_on_pr.check_on_pr('Bloat Difference', '```\n%s\n```' % text)
|
| 121 | +check_on_pr.label_significance_on_pr('bloat', severity) |
0 commit comments