Giter Site home page Giter Site logo

tss's Introduction

tss (1)

tss is like ts from moreutils, but prints relative durations (with millisecond precision) by default, and can be shipped as a compiled binary.

Try it out:

$ (sleep 1; echo "hello"; sleep 2; echo "two sec") | tss
   995ms          hello
      3s   2.005s two sec

The first column is the amount of time that has elapsed since the program started. The second column is the amount of time that has elapsed since the last line printed.

Installation

Find your target operating system (darwin, windows, linux) and desired bin directory, and modify the command below as appropriate:

curl --silent --location --output /usr/local/bin/tss https://github.com/kevinburke/tss/releases/download/0.4/tss-linux-amd64 && chmod 755 /usr/local/bin/tss

The latest version is 0.4.

If you have a Go development environment, you can also install via source code:

go get -u github.com/kevinburke/tss

The corresponding library is available at github.com/kevinburke/tss/lib. View the library documentation at godoc.org.

Usage Notes

  • Piping commands to tss may result in programs buffering their output before flushing it to stdout file descriptor. You can avoid this by wrapping the target program in a command like unbuffer (via the expect package) or stdbuf from the coreutils package. On Macs you can install with brew install expect and brew install coreutils respectively; the stdbuf command may be prefixed with a 'g': gstdbuf.

    stdbuf --output=L <mycommand> | tss
    
  • Piping commands may also change the return code from non-zero to zero, since Bash by default uses the return code of the last command in the pipe to decide how to exit. This means if you are piping output to tss or ts you may accidentally change a failing program to a passing one. Use set -o pipefail in Bash scripts to ensure that Bash will return a non-zero return code if any part of a pipe operation fails. Or add this to a Makefile:

    SHELL = /bin/bash -o pipefail
    

tss's People

Contributors

hasantayyar avatar kevinburke avatar tehshrike avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

tss's Issues

Performance could be better

Probably we can be smarter with allocations and buffer growing etc. to improve performance.

$ make bench
go list ./... | grep -v vendor | xargs go test -benchtime=2s -bench=. -run='^$' 2>&1 | /Users/kevin/bin/benchstat /dev/stdin
name         time/op
Copy-4          131µs ± 0%
Writer-4        152µs ± 0%
WriterBig-4     149µs ± 0%

name         speed
Copy-4       62.4MB/s ± 0%
Writer-4     54.0MB/s ± 0%
WriterBig-4  54.8MB/s ± 0%

name         alloc/op
Copy-4         47.7kB ± 0%
Writer-4       47.2kB ± 0%
WriterBig-4    14.4kB ± 0%

name         allocs/op
Copy-4            991 ± 0%
Writer-4          985 ± 0%
WriterBig-4       984 ± 0%

Add a licence

tss should have a licence of some sort, unless you're going for a POSS project.

Allow profiling as a subcommand

This gives us more control over stdout and also allows us to exit with the same return code of the program under test, e.g. ts -- which foo

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.