Skip to content

Testing language concurrency primitives with a file line counter

License

Notifications You must be signed in to change notification settings

dan-f/concurrent-wc

Repository files navigation

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!

About

Testing language concurrency primitives with a file line counter

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published