Code Monkey home page Code Monkey logo

tgrep's Introduction

tgrep โ€” grep but with time

tgrep is a much simpler version of grep but with a precise scope in mind: print, for each line matched, the delta of time between that line and the previous one.

Why? Personally I use it quite often when I'm debugging a performance related bug.

With tgrep I can easily find where a piece of code took a lot of time or see if some output took much more that others to compute, and that by simply add a couple of logs.

A couple of notice:

  • This is not a benchmark tool. It's not precise enough and make sense to use it only for debug purposes.
  • Do not forget that stdout in a pipe will be buffering. Sometimes you have to turn it off.

Example

$ ./a.out < recipes.txt | tgrep "HALP"
0ns     | starting HALP
148ns   | HALP processing 'coniglio alla ligure'
16us    | HALP processing 'coniglio alla ligure' end
98ns    | HALP processing 'focaccia'
9us     | HALP processing 'focaccia' end
118us   | HALP processing 'pesto con le noci'
69ms    | HALP processing 'pesto con le noci' end
154us   | HALP processing 'torta di riso'
7us     | HALP processing 'torta di riso' end

Installation

$ cargo install --git https://github.com/Bnz-0/tgrep

Usage

$ tgrep -h
Grep but with time

Usage: tgrep [OPTIONS] [PATTERN]

Arguments:
  [PATTERN]

Options:
  -i, --ignore-case           Ignore case distinctions in patterns and data
  -u, --fix-unit <TIME_UNIT>  Fix the unit time used while printing [possible values: ns, us, ms, s]
  -h, --help                  Print help
  -V, --version               Print version

tgrep's People

Contributors

bnz-0 avatar

Watchers

 avatar

tgrep's Issues

Colors!

Color the output to better visualize the difference of time unit.
Otherwise, the risk is to not notice 2ms because a 1058ns took the attention, but it's much less than 2ms.

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.