Testing language concurrency primitives with a file line counter
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
bin
scripts
wc-bash
wc-c/src
wc-go/src
wc-haskell
wc-node
wc-ocaml
wc-python/src
wc-ruby
wc-rust
.gitignore
LICENSE
Makefile
Pipfile
Pipfile.lock
README.md
make-test-files.py

README.md

concurrent-wc

This project is for comparing async and concurrency tools in different languages by implementing a simple wc -l-style utility.

spec

The wc utility should do the following:

  1. Display the number of lines for each regular file in the directory.
  2. Display the cumulative number of lines of all files in the directory.
  3. Optionally take a single command-line argument specifying a different directory.
  4. Sort the files in terms of number of lines, in descending order.
  5. Print the running time, rounded to the nearest integer, in milliseconds

e.g.

$ ./bin/wc-go tmp
        11 tmp/big.txt
         1 tmp/small.txt
        12 [TOTAL]
Took 1ms

implementing

The suggested implementation involves "fanning out" asynchronous tasks to read through each file in the directory and count the lines concurrently. The tasks will need to be synchronized at the end in order to compile the results and sort them for display.

As of commit c89a50e, the go implementation is the reference implementation.

adding a language implementation

The various wc implementations should be put in sub-directories of the top-level directory named wc-$LANGNAME; the go implementation is located in wc-go. The resulting executables should be placed in bin/wc-$LANGNAME; the go executable is located at bin/wc-go.

dependencies

Each language implementation has its own dependencies.

  • wc-go requires go
  • wc-haskell requires the stack build tool
  • wc-node requires node
  • wc-ocaml requires OCaml as well as the async and core packages
  • wc-python requires python3
  • wc-ruby requires ruby
  • wc-rust requires cargo

building

Just run make from the project root. Or if you want to build a particular language implementation, run e.g. make go or make rust.

contributors

Thanks to the following folks!