libsize.py
Go to the documentation of this file.
1 from __future__ import annotations
2 
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(f"Error: requested file ({lib}) does not exist")
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(f" (change of {change:+} bytes = {change / oldsize:+.2%})")
34 else:
35  print()
36 
37 with open(save, "w") as sf:
38  sf.write(str(libsize))
gtsam.examples.DogLegOptimizerExample.int
int
Definition: DogLegOptimizerExample.py:111
Eigen::internal::print
EIGEN_STRONG_INLINE Packet4f print(const Packet4f &a)
Definition: NEON/PacketMath.h:3115
str
Definition: pytypes.h:1558
len
size_t len(handle h)
Get the length of a Python object.
Definition: pytypes.h:2446


gtsam
Author(s):
autogenerated on Sun Dec 22 2024 04:11:55