Skip to content
/ pct Public

pct is a 'sort | uniq -c' replacement that also prints percentages

License

Notifications You must be signed in to change notification settings

josharian/pct

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pct calculates the distribution of lines in text. It is similar to sort | uniq -c | sort -n -r, except that it prints percentages as well as counts.

Sample output:

$ cat std.qc | grep "clearfat" | pct | head
 33.05%    1204    clearfat q=2 c=0
 18.80%    685     clearfat q=4 c=0
 17.76%    647     clearfat q=3 c=0
  4.47%    163     clearfat q=6 c=0
  3.90%    142     clearfat q=8 c=0
  3.84%    140     clearfat q=10 c=0
  2.72%    99      clearfat q=5 c=0
  1.95%    71      clearfat q=13 c=0
  1.73%    63      clearfat q=4 c=4
  1.40%    51      clearfat q=7 c=0

I originally wrote it for compiler investigations, but have found it to be broadly useful.

This kind of tool seems to be prone to convergent evolution: https://blog.mozilla.org/nnethercote/2018/07/24/ad-hoc-profiling/

About

pct is a 'sort | uniq -c' replacement that also prints percentages

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages