Giter Club home page Giter Club logo

pc's Introduction

Usage Example

pc - Change Calculator for the Terminal

pc is a lightweight, blazing-fast tool that simplifies both the calculation and the understanding of differences between numbers. It allows you to quickly evaluate performance changes and offers meaningful human-formatted output, all within the convenience of your terminal.

โœจ Features

  • ๐Ÿ”ฅ Fashionable Output: Human readable, colorful, and easy to understand
  • ๐ŸŽฏ Always Accurate: Calculates percent change correctly every time
  • ๐Ÿš€ Blazing Fast: Don't wait, get your results instantly
  • โค๏ธ Zig-Powered: Crafted with love using Zig

๐Ÿ› ๏ธ Usage

๐Ÿ’ป Basic Calculation

Compute percentage changes and differences effortlessly:

โฏ pc 18024 19503 11124 12321 340200 424212 1000000000
โ†‘    8.21%  1.08x  [ 17.60KiB โ†’ 19.05KiB ]
โ†“   -43.0%  0.57x  [  19.0KiB โ†’ 10.9KiB  ]
โ†‘    10.8%  1.11x  [  10.9KiB โ†’ 12.0KiB  ]
โ†‘    2661%  27.6x  [    12KiB โ†’ 332KiB   ]
โ†‘    24.7%  1.25x  [ 332.2KiB โ†’ 414.3KiB ]
โ†‘  235631%  2357x  [   414KiB โ†’ 954MiB   ]

๐ŸŽ“ Friendly Sizes by Default

Large numbers are automatically translated into familiar sizes like GiB, MiB, KiB:

โฏ pc 1124122523 2421252122
โ†‘  115.4%  2.15x  [ 1.0GiB โ†’ 2.3GiB ]

Need raw numbers? Use the -r option:

โฏ pc 1124122523 2421252122 -r
โ†‘  115.4%  2.15x  [ 1124122496 โ†’ 2421252096 ]

๐Ÿ”€ Flexibility with Delimiters

By default, pc tokenizes the input with the default delimiters ( \n\t\r,;:|). Use the --delimiters or -d option to specify additional delimiters:

โฏ echo "15@20@3 6" | pc -d "@"
โ†‘  33.3%  1.33x  [ 15 โ†’ 20 ]
โ†“   -85%  0.15x  [ 20 โ†’ 3  ]
โ†‘   100%     2x  [  3 โ†’ 6  ]

๐Ÿ“ Fixed Calculation

Use the --fixed or -f flags to evaluate changes relative to a specific reference point in your series. You can specify positive or negative indices to choose the reference number.

Evaluate changes relative to the first number (default):

โฏ pc 1 2 3 4 -f
โ†‘  100%  2x  [ 1 โ†’ 2 ]
โ†‘  200%  3x  [ 1 โ†’ 3 ]
โ†‘  300%  4x  [ 1 โ†’ 4 ]

Or choose a different reference point (one-based):

โฏ pc 1 2 3 4 -f 2
โ†“  -50%  0.50x  [ 2 โ†’ 1 ]
โ†‘   50%  1.50x  [ 2 โ†’ 3 ]
โ†‘  100%     2x  [ 2 โ†’ 4 ]

Or index from the end of the series with negative numbers:

โฏ pc 1 2 3 4 -f -1
โ†“  -75%  0.25x  [ 4 โ†’ 1 ]
โ†“  -50%  0.50x  [ 4 โ†’ 2 ]
โ†“  -25%  0.75x  [ 4 โ†’ 3 ]

๐Ÿ“„ Output Formats

Specify the output format with the --format option. Currently, pc supports the following formats:

  • Human-readable (default)
  • JSON
  • CSV

JSON Output

โฏ pc 18024 19503 --format json | jq
[
  {
    "percent": 8.20572566986084,
    "times": 1.082057237625122,
    "prev": 18024,
    "cur": 19503
  }
]

CSV Output

โฏ pc 18024 19503 --format csv
percent,times,prev,cur
8.20572566986084,1.082057237625122,18024,19503

For the full command list, simply run:

pc --help

๐Ÿ“ฅ Installation

Prebuilt Binaries Available

Find them on the releases page.

Supported Releases

  • Linux: aarch64-linux-pc, riscv64-linux-pc, x86_64-linux-pc
  • macOS: aarch64-macos-pc
  • Windows: x86_64-windows-pc.exe

Installation Example for Linux (x86_64)

wget -O pc https://github.com/cgbur/pc/releases/latest/download/x86_64-linux-pc
chmod +x pc
mv pc ~/.local/bin/pc

Replace the file name in the URL with the corresponding one for other Linux architectures.

Build from Source

To build from source, you'll need Zig:

git clone https://github.com/cgbur/pc.git
cd pc
zig build -Doptimize=ReleaseSafe
cp zig-out/bin/pc ~/.local/bin/pc

๐Ÿ“ Future Plans

  • Think of more features to add

pc's People

Contributors

cgbur avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

gungorfeyz

pc's Issues

Add a way to reverse calculation direction

https://crates.io/crates/hashbrown

In this example, when they compare two numbers, they give a percent reduction from the before to the after then they give the multiplication as a speed increase. I wonder if there's some way to either do this automatically all the time, which might be questionable, or just add a flag that we can pass at the end of a statement to reverse the calculation that was done, like a-r/--reverse flag. This way you can just press up in the terminal and then add the flag and get the inverse.

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.