wc

package module
v0.0.0-...-fde1043 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 13, 2014 License: MIT Imports: 7 Imported by: 3 modules, 2 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

#wc a faster wc (mostly)

  • Same speed as native wc for line/byte counts.
  • 3x faster word counts
  • 30x faster multibyte runes counts

Relies on performance gained from multithreaded processing on buffer chunks.

./wc [-l] [-m] [-w] [-b] file [...fileN]
  -c=false: count bytes
  -l=false: count lines
  -m=false: count multibyte runes
  -w=false: count words

# count lines
time ./wc -l 100m.lines;
 100000000 100m.lines

real	0m1.155s
user	0m3.875s
sys	    0m0.389s

time wc -l 100m.lines 
 100000000 100m.lines

real	0m1.138s
user	0m0.920s
sys	    0m0.209s

# count words
time ./wc -w 100m.lines;
 108339058 100m.lines

real	0m2.119s
user	0m7.289s
sys	    0m0.438s

time wc -w 100m.lines 
 108339058 100m.lines

real	0m5.888s
user	0m5.650s
sys	    0m0.237s

# count multibyte characters
time ./wc -m 100m.lines;
 1093761047 100m.lines

real	0m0.677s
user	0m1.981s
sys	    0m0.348s

time wc -m 100m.lines 
 1093761047 100m.lines

real	0m18.468s
user	0m18.186s
sys	    0m0.268s

# count bytes
time ./wc -c 100m.lines;
 1093761047 100m.lines

real	0m0.420s
user	0m0.176s
sys	    0m0.298s

time wc -c 100m.lines 
 1093761047 100m.lines

real	0m0.003s
user	0m0.001s
sys	    0m0.002s

/usr/sbin/system_profiler -detailLevel full SPHardwareDataType
Hardware:

    Hardware Overview:

      Model Name: MacBook Air
      Model Identifier: MacBookAir6,2
      Processor Name: Intel Core i5
      Processor Speed: 1.3 GHz
      Number of Processors: 1
      Total Number of Cores: 2
      L2 Cache (per Core): 256 KB
      L3 Cache: 3 MB
      Memory: 4 GB
      ...

##Build and Use

git clone git@github.com:jasonmoo/wc.git
cd wc/cmd
go get
go build wc.go

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BufferSize = 4 << 20

Functions

This section is empty.

Types

type Counter

type Counter struct {
	Multibytes uint64
	Bytes      uint64
	Lines      uint64
	Words      uint64
	// contains filtered or unexported fields
}

func NewCounter

func NewCounter(f *os.File) *Counter

func (*Counter) Count

func (c *Counter) Count(count_multibytes, count_bytes, count_lines, count_words bool) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址