Command line filter that only prints unique lines
Similar to uniq
but does not require input lines to be sorted.
$ who | unique
Command line filter that only prints unique lines
License: MIT License
Thanks for the utility, it was very useful.
However when I'm comparing the performance with awk
script, it's slower.
awk
$ seq 20000000 | time awk '!a[$0]++{print}' | pv -l >/dev/null
22.67user 0.87system 0:23.55elapsed 99%CPU (0avgtext+0avgdata 1616164maxresident)
0inputs+0outputs (0major+403562minor)pagefaults 0swaps
20.0M 0:00:23 [ 849k/s]
unique
$ seq 20000000 | time unique | pv -l >/dev/null
19.68user 10.32system 0:29.74elapsed 100%CPU (0avgtext+0avgdata 860364maxresident)
0inputs+0outputs (0major+224737minor)pagefaults 0swaps
20.0M 0:00:29 [ 672k/s]
awk
$ echo | pee "seq 10000000" "seq 10000000" "seq 10000000" | time awk '!a[$0]++{print}' | pv -l | wc -l
14.37user 0.64system 0:15.02elapsed 99%CPU (0avgtext+0avgdata 825032maxresident)
0inputs+0outputs (0major+205782minor)pagefaults 0swaps
10.0M 0:00:15 [ 665k/s]
10000522
unique
$ echo | pee "seq 10000000" "seq 10000000" "seq 10000000" | time unique | pv -l | wc -l
12.67user 5.49system 0:18.02elapsed 100%CPU (0avgtext+0avgdata 431976maxresident)
0inputs+0outputs (0major+115640minor)pagefaults 0swaps
10.0M 0:00:18 [ 554k/s]
10000216
Why the performance is slower than the scripting language?
Are there any methods of improving the performance?
The only plus is that it's using much less memory.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.