Skip to content

Instantly share code, notes, and snippets.

@17g
Last active February 3, 2018 10:17
Show Gist options
  • Save 17g/0741527eb6ba7df226ec5a2009c8c21b to your computer and use it in GitHub Desktop.
Save 17g/0741527eb6ba7df226ec5a2009c8c21b to your computer and use it in GitHub Desktop.
Rust で tail コマンドを実装してみた ref: https://qiita.com/17g/items/e4bc81e5c2c8428858a7
$ cargo -V
cargo 0.24.0 (45043115c 2017-12-05)
$ rustc -V
rustc 1.23.0 (766bd11c8 2018-01-01)
Usage: rtail [options] FILE
Options:
-n NUMS number of lines
-h print help
$ time tail -n 10000 120000.log
tail -n 10000 120000.log 0.06s user 0.02s system 30% cpu 0.251 total
$ time ./target/debug/rtail -n 10000 120000.log
./target/debug/rtail -n 10000 120000.log 0.63s user 1.15s system 90% cpu 1.979 total
$ time ./target/release/rtail -n 10000 120000.log
./target/release/rtail -n 10000 120000.log 0.26s user 1.14s system 87% cpu 1.591 total
$ time ./target/debug/rtail -n 10000 120000.log
./target/debug/rtail -n 10000 120000.log 0.09s user 0.01s system 70% cpu 0.132 total
$ time ./target/release/rtail -n 10000 120000.log
./target/release/rtail -n 10000 120000.log 0.00s user 0.01s system 7% cpu 0.205 total
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment