sleepycat

Crates.iosleepycat
lib.rssleepycat
version0.1.2
sourcesrc
created_at2019-07-05 14:24:04.450779
updated_at2019-07-05 15:18:32.335407
descriptionSlow down your data
homepagehttps://github.com/daniellockyer/sleepycat
repositoryhttps://github.com/daniellockyer/sleepycat
max_upload_size
id146564
size18,217
Daniel Lockyer (daniellockyer)

documentation

README

:cat2: sleepycat

Build Status MIT licensed

sleepycat takes in data from stdin and outputs on stdout at a given number of lines per second (LPS).

Why

I was writing a program to parse a log file and draw graphs in real-time. I needed a way to repeatedly test it without generating log files from the source application. sleepycat was born so I could reuse the same log file and pipe it into my application at a customizable rate.

Sure, you could do it in Bash with some clever scripting, but I wanted the ability to add in some custom patterns at some point.

Installation

You have several ways to get sleepycat:

  1. Download from crates.io: cargo install sleepycat
  2. *Coming Soon* Download a prebuilt binary from the releases page.
  3. Build it yourself.
    1. Clone this repo: git clone https://github.com/daniellockyer/sleepycat
    2. Build the binary in release mode: cargo build --release
    3. The binary is available at target/release/sleepycat

Accuracy

Right now, this project is just an attempt to get something running. It doesn't take into account the time it takes to print a line, so it sleeps for too long and the actual LPS ends up being lower than the target. It's not so much of a big deal with smaller targets, but it struggles to reach higher numbers.

You can test the accuracy using the following command:

cargo run --release < access.log | pv --line-mode --rate > /dev/null
  • For a target of 10 LPS, it reaches 9.99.
  • For a target of 100 LPS, it reaches 98.1.
  • For a target of 500 LPS, it reaches 460.
Commit count: 28

cargo fmt