mirror of
https://github.com/motioneye-project/motioneyeos.git
synced 2025-07-30 06:36:34 +00:00
support/graph-size: add option to change percentage to group in Others
Currently, we group packages that contribute less then 1%, into the "Other" category. However, in some cases, there can be a lot of very comparatively small packages, and they may not exceed this limit, and so only the "Others" category would be displayed, which is not nice. Conversely, if there are a lot of packages, most of which only so slightly exceeding this limit, then we get all of them in the graph, which is not nice either. Add a way for the developers to pass a different cut-off limit. As for the dependency graph which has BR2_GRAPH_DEPS_OPTS, add the environment variable BR2_GRAPH_SIZE_OPTS to carry those extra option (in preparation for more to come, later). Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr> Cc: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com> [Arnout: - remove empty base class definition from Config; - use parser.error instead of ValueError for invalid argument.] Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
This commit is contained in:
parent
3fc3c4ac99
commit
e9cdabee71
3
Makefile
3
Makefile
@ -892,7 +892,8 @@ graph-size:
|
|||||||
$(Q)$(TOPDIR)/support/scripts/size-stats --builddir $(BASE_DIR) \
|
$(Q)$(TOPDIR)/support/scripts/size-stats --builddir $(BASE_DIR) \
|
||||||
--graph $(GRAPHS_DIR)/graph-size.$(BR_GRAPH_OUT) \
|
--graph $(GRAPHS_DIR)/graph-size.$(BR_GRAPH_OUT) \
|
||||||
--file-size-csv $(GRAPHS_DIR)/file-size-stats.csv \
|
--file-size-csv $(GRAPHS_DIR)/file-size-stats.csv \
|
||||||
--package-size-csv $(GRAPHS_DIR)/package-size-stats.csv
|
--package-size-csv $(GRAPHS_DIR)/package-size-stats.csv \
|
||||||
|
$(BR2_GRAPH_SIZE_OPTS)
|
||||||
|
|
||||||
.PHONY: check-dependencies
|
.PHONY: check-dependencies
|
||||||
check-dependencies:
|
check-dependencies:
|
||||||
|
@ -102,6 +102,8 @@ to +make+ or set in the environment:
|
|||||||
xref:graph-depends[] for the accepted options
|
xref:graph-depends[] for the accepted options
|
||||||
* +BR2_GRAPH_DOT_OPTS+ is passed verbatim as options to the +dot+ utility to
|
* +BR2_GRAPH_DOT_OPTS+ is passed verbatim as options to the +dot+ utility to
|
||||||
draw the dependency graph.
|
draw the dependency graph.
|
||||||
|
* +BR2_GRAPH_SIZE_OPTS+ to pass extra options to the size graph; see
|
||||||
|
xref:graph-size[] for the acepted options
|
||||||
|
|
||||||
An example that uses config files located in the toplevel directory and
|
An example that uses config files located in the toplevel directory and
|
||||||
in your $HOME:
|
in your $HOME:
|
||||||
@ -278,6 +280,7 @@ only other format supported is PNG:
|
|||||||
BR2_GRAPH_OUT=png make graph-build
|
BR2_GRAPH_OUT=png make graph-build
|
||||||
----------------
|
----------------
|
||||||
|
|
||||||
|
[[graph-size]]
|
||||||
=== Graphing the filesystem size contribution of packages
|
=== Graphing the filesystem size contribution of packages
|
||||||
|
|
||||||
When your target system grows, it is sometimes useful to understand
|
When your target system grows, it is sometimes useful to understand
|
||||||
@ -314,6 +317,15 @@ Just like for the duration graph, a +BR2_GRAPH_OUT+ environment is
|
|||||||
supported to adjust the output file format. See xref:graph-depends[]
|
supported to adjust the output file format. See xref:graph-depends[]
|
||||||
for details about this environment variable.
|
for details about this environment variable.
|
||||||
|
|
||||||
|
Additionally, one may set the environment variable +BR2_GRAPH_SIZE_OPTS+
|
||||||
|
to further control the generated graph. Accepted options are:
|
||||||
|
|
||||||
|
* `--size-limit X`, `-l X`, will group all packages which individual
|
||||||
|
contribution is below `X` percent, to a single entry labelled _Others_
|
||||||
|
in the graph. By default, `X=0.01`, which means packages each
|
||||||
|
contributing less than 1% are grouped under _Others_. Accepted values
|
||||||
|
are in the range `[0.0..1.0]`.
|
||||||
|
|
||||||
.Note
|
.Note
|
||||||
The collected filesystem size data is only meaningful after a complete
|
The collected filesystem size data is only meaningful after a complete
|
||||||
clean rebuild. Be sure to run +make clean all+ before using +make
|
clean rebuild. Be sure to run +make clean all+ before using +make
|
||||||
|
@ -33,6 +33,9 @@ except ImportError:
|
|||||||
sys.stderr.write("You need python-matplotlib to generate the size graph\n")
|
sys.stderr.write("You need python-matplotlib to generate the size graph\n")
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
|
|
||||||
|
class Config:
|
||||||
|
size_limit = 0.01
|
||||||
colors = ['#e60004', '#009836', '#2e1d86', '#ffed00',
|
colors = ['#e60004', '#009836', '#2e1d86', '#ffed00',
|
||||||
'#0068b5', '#f28e00', '#940084', '#97c000']
|
'#0068b5', '#f28e00', '#940084', '#97c000']
|
||||||
|
|
||||||
@ -145,7 +148,7 @@ def draw_graph(pkgsize, outputf):
|
|||||||
other_value = 0
|
other_value = 0
|
||||||
unknown_value = 0
|
unknown_value = 0
|
||||||
for (p, sz) in sorted(pkgsize.items(), key=lambda x: x[1]):
|
for (p, sz) in sorted(pkgsize.items(), key=lambda x: x[1]):
|
||||||
if sz < (total * 0.01):
|
if sz < (total * Config.size_limit):
|
||||||
other_value += sz
|
other_value += sz
|
||||||
elif p == "unknown":
|
elif p == "unknown":
|
||||||
unknown_value = sz
|
unknown_value = sz
|
||||||
@ -162,7 +165,7 @@ def draw_graph(pkgsize, outputf):
|
|||||||
plt.figure()
|
plt.figure()
|
||||||
patches, texts, autotexts = plt.pie(values, labels=labels,
|
patches, texts, autotexts = plt.pie(values, labels=labels,
|
||||||
autopct='%1.1f%%', shadow=True,
|
autopct='%1.1f%%', shadow=True,
|
||||||
colors=colors)
|
colors=Config.colors)
|
||||||
# Reduce text size
|
# Reduce text size
|
||||||
proptease = fm.FontProperties()
|
proptease = fm.FontProperties()
|
||||||
proptease.set_size('xx-small')
|
proptease.set_size('xx-small')
|
||||||
@ -246,8 +249,16 @@ def main():
|
|||||||
help="CSV output file with file size statistics")
|
help="CSV output file with file size statistics")
|
||||||
parser.add_argument("--package-size-csv", '-p', metavar="PKG_SIZE_CSV",
|
parser.add_argument("--package-size-csv", '-p', metavar="PKG_SIZE_CSV",
|
||||||
help="CSV output file with package size statistics")
|
help="CSV output file with package size statistics")
|
||||||
|
parser.add_argument("--size-limit", "-l", type=float,
|
||||||
|
help='Under this size ratio, files are accounted to ' +
|
||||||
|
'the generic "Other" package. Default: 0.01 (1%%)')
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
if args.size_limit is not None:
|
||||||
|
if args.size_limit < 0.0 or args.size_limit > 1.0:
|
||||||
|
parser.error("--size-limit must be in [0.0..1.0]")
|
||||||
|
Config.size_limit = args.size_limit
|
||||||
|
|
||||||
# Find out which package installed what files
|
# Find out which package installed what files
|
||||||
pkgdict = build_package_dict(args.builddir)
|
pkgdict = build_package_dict(args.builddir)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user