GithubHelp home page GithubHelp logo

jfrimmel / cargo-size Goto Github PK

View Code? Open in Web Editor NEW
2.0 0.0 0.0 15 KB

a custom command extending 'cargo' to print the memory usage

License: MIT License

Rust 100.00%
rust cargo cargo-subcommand cargo-plugin size-calculation

cargo-size's Introduction

cargo-size

a custom command extending cargo to print the memory usage

Dependencies

  • cargo is required for building the crate you want to display the size of.

Usage

Executing cargo size in a crate (root or a subdirectory) with a file memory.x present in the crate root builds the development binary and prints an output similar to:

$ cargo size
   Finished dev [unoptimized + debuginfo] target(s) in 0.37s
   Printing Memory Usage
            ------------
            Program:   55652 bytes (42.5% full)
            Data:          8 bytes (0.0% full)

The command cargo size --release does the same, but builds the release binary if necessary and prints its size.

If the file memory.x is not found or is invalid the percentages are omitted, without any error or warning message:

$ cargo size
   Finished dev [unoptimized + debuginfo] target(s) in 0.01s
   Printing Memory Usage
            ------------
            Program: 1486351 bytes
            Data:       4656 bytes

The file memory.x has to contain a MEMORY directive with at least the two sections flash and ram (case is ignored). The size of those two memories is used to calculate the percentages.

If the binary (either the development or the release one, as specified) is not up-to-date, cargo is used to build it.

Errors

If any error is detected, the application emits an error message and exits with the exit code 1 to indicate failure.

Possible errors include:

  • The program was started in a directory, which is not a cargo project (subdirectories of such a project are perfectly fine).
  • The manifest file Cargo.toml is present, but could not be parsed, e.g. the crate name is missing.
  • The build command failed, e.g. the code contains an error.
  • The binary was built successfully, but could not be found in the target directory. This is most likely if you are cross-compiling code for another platform. Then the binary is located in a subdirectory named as the target. The application tries some known platform, but if yours is not known yet, the command will fail.
  • The binary has an invalid format, e.g. it is not an ELF-file or it is corrupt.

cargo-size's People

Contributors

jfrimmel avatar

Stargazers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.