-
Notifications
You must be signed in to change notification settings - Fork 177
/
Copy pathtest_bloat.py
29 lines (25 loc) · 1.03 KB
/
test_bloat.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import os, errno, subprocess, sys
def callCommand(command):
process = subprocess.Popen(command, stdout=subprocess.PIPE)
process.communicate()
process.wait()
def main():
dir = "test_bloat"
try:
os.makedirs(dir)
except OSError as e:
if e.errno != errno.EEXIST:
raise
os.chdir(dir)
callCommand(["cmake", ".."])
callCommand(["cmake", "--build", ".", "--config", "Debug"])
callCommand(["cmake", "--build", ".", "--config", "Release"])
os.chdir("..")
print ("| Config | Plain string literals | Obfuscated strings | Bloat |")
print ("|:------:|:---------------------:|:------------------:|:-----:|")
for config in ["Release", "Debug"]:
sizeOn = os.stat(os.path.join(dir, config, "test_bloat_on.exe")).st_size
sizeOff = os.stat(os.path.join(dir, config, "test_bloat_off.exe")).st_size
print ("| {} | {} | {} | {} ({:.1f}%) |".format(config, sizeOff, sizeOn, sizeOn - sizeOff, (sizeOn / sizeOff - 1.0) * 100))
if __name__ == "__main__":
main()