libsize.py
Go to the documentation of this file.
1 # -*- coding: utf-8 -*-
2 from __future__ import print_function, division
3 import os
4 import sys
5 
6 # Internal build script for generating debugging test .so size.
7 # Usage:
8 # python libsize.py file.so save.txt -- displays the size of file.so and, if save.txt exists, compares it to the
9 # size in it, then overwrites save.txt with the new size for future runs.
10 
11 if len(sys.argv) != 3:
12  sys.exit("Invalid arguments: usage: python libsize.py file.so save.txt")
13 
14 lib = sys.argv[1]
15 save = sys.argv[2]
16 
17 if not os.path.exists(lib):
18  sys.exit("Error: requested file ({}) does not exist".format(lib))
19 
20 libsize = os.path.getsize(lib)
21 
22 print("------", os.path.basename(lib), "file size:", libsize, end='')
23 
24 if os.path.exists(save):
25  with open(save) as sf:
26  oldsize = int(sf.readline())
27 
28  if oldsize > 0:
29  change = libsize - oldsize
30  if change == 0:
31  print(" (no change)")
32  else:
33  print(" (change of {:+} bytes = {:+.2%})".format(change, change / oldsize))
34 else:
35  print()
36 
37 with open(save, 'w') as sf:
38  sf.write(str(libsize))
void print(const Matrix &A, const string &s, ostream &stream)
Definition: Matrix.cpp:155
return int(ret)+1
Definition: pytypes.h:928
size_t len(handle h)
Definition: pytypes.h:1514


gtsam
Author(s):
autogenerated on Sat May 8 2021 02:42:31