#可执行文件 #大小 #空间 #elf #pe #mach-o #find

app cargo-bloat

找出占用可执行文件空间最多的内容

32 个版本

0.12.1 2024 年 5 月 10 日
0.11.1 2022 年 6 月 4 日
0.11.0 2021 年 12 月 30 日
0.10.1 2021 年 7 月 3 日
0.2.2 2018 年 2 月 18 日

#11Cargo 插件

Download history 956/week @ 2024-05-03 1720/week @ 2024-05-10 857/week @ 2024-05-17 744/week @ 2024-05-24 934/week @ 2024-05-31 673/week @ 2024-06-07 581/week @ 2024-06-14 623/week @ 2024-06-21 579/week @ 2024-06-28 1424/week @ 2024-07-05 1925/week @ 2024-07-12 2022/week @ 2024-07-19 2141/week @ 2024-07-26 1935/week @ 2024-08-02 1823/week @ 2024-08-09 1700/week @ 2024-08-16

7,851 每月下载次数

MIT 许可证

58KB
1.5K SLoC

cargo-bloat

找出占用可执行文件空间最多的内容。

支持 ELF (Linux, BSD)、Mach-O (macOS) 和 PE (Windows) 二进制文件。

不支持 WASM。请使用 twiggy 代替。

google/bloaty 启发。

安装

cargo install cargo-bloat

或者

cargo install cargo-bloat --no-default-features

如果不使用 --filter 选项进行正则表达式过滤。

用法

获取发布构建中最大的函数列表

% cargo bloat --release -n 10
Compiling ...
Analyzing target/release/cargo-bloat

 File  .text     Size       Crate Name
 0.9%   7.1%  27.0KiB cargo_bloat cargo_bloat::main
 0.8%   5.7%  21.4KiB cargo_bloat cargo_bloat::process_crate
 0.3%   2.3%   8.6KiB   [Unknown] read_line_info
 0.3%   2.1%   7.9KiB         std std::sys::unix::process::process_common::Command::capture_env
 0.3%   2.1%   7.8KiB        json json::parser::Parser::parse
 0.2%   1.7%   6.5KiB   [Unknown] elf_add
 0.2%   1.7%   6.3KiB         std __rdos_backtrace_dwarf_add
 0.2%   1.3%   5.0KiB         std <rustc_demangle::legacy::Demangle as core::fmt::Display>::fmt
 0.2%   1.3%   4.9KiB         std std::sys_common::backtrace::_print
 0.2%   1.3%   4.8KiB         std core::num::flt2dec::strategy::dragon::format_shortest
 9.8%  73.5% 278.0KiB             And 932 smaller methods. Use -n N to show more.
13.3% 100.0% 378.0KiB             .text section size, the file size is 2.8MiB

获取发布构建中最大的依赖列表

% cargo bloat --release --crates
Compiling ...
Analyzing target/release/cargo-bloat

 File  .text     Size Crate
 8.1%  61.2% 231.5KiB std
 2.5%  19.2%  72.4KiB cargo_bloat
 1.2%   9.4%  35.5KiB [Unknown]
 1.0%   7.2%  27.2KiB json
 0.3%   2.2%   8.5KiB pico_args
 0.1%   0.4%   1.7KiB multimap
 0.0%   0.3%   1.1KiB memmap
 0.0%   0.0%     175B term_size
 0.0%   0.0%      45B time
13.3% 100.0% 378.0KiB .text section size, the file size is 2.8MiB

Note: numbers above are a result of guesswork. They are not 100% correct and never will be.

通过正则表达式过滤获取发布构建中最大的函数列表

注意:您必须使用启用了 regex-filter 特性的方式构建 cargo-bloat

% cargo bloat --release --filter '^__' -n 10
Compiling ...
Analyzing target/release/cargo-bloat

File .text    Size Crate Name
0.2%  1.7%  6.3KiB   std __rdos_backtrace_dwarf_add
0.1%  0.5%  1.9KiB   std __rdos_backtrace_qsort
0.0%  0.2%    843B   std __udivmodti4
0.0%  0.1%    296B   std __floattidf
0.0%  0.1%    290B   std __floattisf
0.0%  0.1%    284B   std __rdos_backtrace_initialize
0.0%  0.1%    253B   std __floatuntisf
0.0%  0.1%    253B   std __floatuntidf
0.0%  0.1%    211B   std __rdos_backtrace_get_view
0.0%  0.0%    180B   std __rdos_backtrace_vector_grow
0.1%  0.7%  2.8KiB       And 37 smaller methods. Use -n N to show more.
0.5%  3.6% 13.5KiB       filtered data size, the file size is 2.8MiB

针对 cargo-bloat 的特定标志

    --crates                   Per crate bloatedness
    --filter <CRATE|REGEXP>    Filter functions by crate
    --split-std                Split the 'std' crate to original crates like core, alloc, etc.
    --no-relative-size         Hide 'File' and '.text' columns
    --full-fn                  Print full function name with hash values
-n <NUM>                       Number of lines to show, 0 to show all [default: 20]
-w, --wide                     Do not trim long function names
    --message-format <FMT>     Output format [default: table] [possible values: table, json]

许可证

cargo-bloat 基于 MIT 许可证。

依赖项

~1.3–2.2MB
~38K SLoC