Skip to content
/ nak Public
forked from cloud9ide/nak

ack and ag inspired tool written in Node. Designed to be fast.

Notifications You must be signed in to change notification settings

fjakobs/nak

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

An ack clone written in Node.js. The focus here is on speed and performance, rather than trying to 100% mimic all the functionality of ack.

There were two goals set out:

  1. Be faster than ack
  2. Return matches in order

I've benchmarked in numerous places where and why code is written as it is, as well as possible areas of improvement. It's mostly asynchronous, though due to the requirement of returning items in order, performs a mergesort at the end of all the results obtained.

As long as it's faster than ack, I'm pleased.

Behavior

A lot of the functionality is modeled around ag. In fact, you can provide an .nakignore file to define patterns to ignore. .nakignore files in the directory you're searching under are automatically included as ignore rules, but you can choose to specify an additional file with -a.

Why?

After reading Felix's Faster than C notes, I became inspired to just write a fast ack clone, in Node.js.

Previously, TJ had written an ack clone in Node, but his code was not very performant. At least, it was slower than ack.

I benchmarked and rewrote and learned a lot. While nak does not support everything ack does, it does nearly everything ag does, and, at least, 100% supports everything we need for Cloud9.

Benchmarks

You like numbers? Me too. They're fun.

Here's the average time for grabbing the filelist in cloud9infra five times (about 33,761 files). The commands do the exact same thing (get hidden files, e.t.c.) and exclude the same nonsense directories ( .git, .c9revisions, sm backups, e.t.c.). :

ag nak ack find
0m0.184s 0m0.940s 0m1.103s 0m1.093s

Here are benchmarks for finding the phrase "va" in cloud9infra:

ag nak ack grep
0m2.599s 0m20.021s 0m29.876s 0m20.891s

Testing

All tests (and comparissons to ag) can be found in tests, and uses [mocha](http://visionmedia.github.com/mocha/) to run. Just call mocha filelist or mocha search.

History

For a discussion on this tool versus ag, find, and grep, see this pull request into Cloud9.

About

ack and ag inspired tool written in Node. Designed to be fast.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published