mirror of
https://github.com/signalapp/libsignal.git
synced 2024-09-20 03:52:17 +02:00
1142c5f43c
Sample output: current build is 0% larger than v0.3.4 (current: 1957208 bytes, v0.3.4: 1949016 bytes) 0.1.5: *********** (1079472 bytes) 0.1.6: *********** (1153216 bytes) 0.1.7: *********** (1153216 bytes) 0.2.0: ************ (1222832 bytes) 0.2.2: ************* (1267888 bytes) 0.2.2: ************** (1382592 bytes) 0.2.3: *************** (1489088 bytes) 0.3.4: ******************* (1949016 bytes) current: ******************* (1957208 bytes)
59 lines
1.5 KiB
Python
Executable File
59 lines
1.5 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
|
|
#
|
|
# Copyright (C) 2021 Signal Messenger, LLC.
|
|
# SPDX-License-Identifier: AGPL-3.0-only
|
|
#
|
|
|
|
import os
|
|
import json
|
|
import sys
|
|
|
|
|
|
def warn(message):
|
|
if 'GITHUB_ACTIONS' in os.environ:
|
|
print("::warning ::" + message)
|
|
else:
|
|
print("warning: " + message, file=sys.stderr)
|
|
|
|
|
|
our_abs_dir = os.path.dirname(os.path.realpath(__file__))
|
|
|
|
lib_size = os.path.getsize(os.path.join(
|
|
our_abs_dir, 'android', 'src', 'main', 'jniLibs', 'arm64-v8a', 'libsignal_jni.so'))
|
|
|
|
with open(os.path.join(our_abs_dir, 'code_size.json')) as old_sizes_file:
|
|
old_sizes = json.load(old_sizes_file)
|
|
|
|
most_recent_tag_size = old_sizes[-1]
|
|
delta = lib_size - most_recent_tag_size['size']
|
|
delta_fraction = (float(delta) / most_recent_tag_size['size'])
|
|
message = "current build is {0}% larger than v{1} (current: {2} bytes, v{1}: {3} bytes)".format(
|
|
int(delta_fraction * 100),
|
|
most_recent_tag_size['version'],
|
|
lib_size,
|
|
most_recent_tag_size['size']
|
|
)
|
|
if delta_fraction > 0.10:
|
|
warn(message)
|
|
else:
|
|
print(message)
|
|
|
|
|
|
def print_plot(sizes):
|
|
highest_size = max(recent_sizes, key=lambda x: x['size'])['size']
|
|
|
|
scale = 1 * 1024 * 1024
|
|
while scale < highest_size:
|
|
scale *= 2
|
|
scale /= 20
|
|
|
|
for entry in sizes:
|
|
bucket = int(entry['size'] / scale) + 1
|
|
print('{:>12}: {} ({} bytes)'.format(entry['version'], '*' * bucket, entry['size']))
|
|
|
|
|
|
recent_sizes = old_sizes[-10:]
|
|
recent_sizes.append({'version': 'current', 'size': lib_size})
|
|
print_plot(recent_sizes)
|