Giter VIP home page Giter VIP logo

shell-timeit's Introduction

shell-timeit

timeit runs a shell command multiple times, measures the execution time of each run, and prints the min/max/average times. It can also collect results in a file and create a diagram of all collected results.

Shell Timeit was inspired by the Python Timeit module.

Example

Run dd for in-memory copying with different block sizes:

  • each size is tested five times (-r 5) instead of the default of three times
  • the command is executed as shell command to allow redirecting output to /dev/null (-s)
  • results are written to dd.json (-f dd.json)
  • a comment is added for every test (-m ...)
  • results are afterwards turned into a diagram (-o dd.png)
for s in 1 2 5 10 20 50 100 200 500 1000 2000 5000 10000 20000 50000; do
    echo "testing with bs="$s"kB"
    timeit -r 5 -s -f dd.json -m "block size: $s kB" "dd if=/dev/zero of=/dev/null bs=$s"kB" count=$((1000000/$s)) >/dev/null 2>&1"
done
timeit -f dd.json -o dd.png

Result:

dd.json diagram

The bars show the lowest execution time; the small dots are the results of each single run.

The diagram displays lowest time prominently because this is the fastest time that was achievable with the specified settings; the higher values just indicate that something interfered with the run.

By default the diagram shows "wallclock seconds", ie. elapsed time, and also system and user CPU time. Other types of measurement can be displayed by specifying the measurement name before the diagram output file name, separated by "=". Multiple measurements can be displayed in a single diagram by listing their names separated by ",". Measurement values can be stacked by separating their names with "+".

Hence, the default diagram style can also be achieved like this:
timeit -f dd.json -o wallclock,ru_utime+ru_stime=dd.png

For a list of available measurement names, refer to the documentation of Python resource module or the getrusage(2) man page.

Alternative Tools

Similar to git-timeit:

shell-timeit's People

Contributors

oliver avatar

Stargazers

 avatar  avatar

Watchers

 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.