Ring Erlang exercise implemented in several languages.
Taken from "Programming Erlang", second edition (by Joe Armstrong):
Write a ring benchmark. Create N processes in a ring. Send a message
round the ring M times so that a total of N * M messages get sent. Time
how long this takes for different values of N and M.
Write a similar program in some other programming language you are
familiar with. Compare the results. Write a blog, and publish the results
on the Internet!
To participate to the benchmark, you must adopt on the following guidelines:
- every implementation shall expose an executable file (bash script or program) named
ring - every implementation shall agree on the following API when
ringis invoked:./ring NumberOfNodes NumberOfTripswhere:NumberOfNodes: the number of processes/threads/nodes in the ring,Nin the description aboveNumberOfTrips: the number of times a message is passed in the ring,Min the description above- returned value of the script should be
0if ok - in case of errors, nothing shall be written on stdout (you can write on stderr), and error code shall be different than
0
- every implementation shall measure the time interval
T0used to setup the ring - every implementation shall measure the time interval
T1in milliseconds between the instant the first message is sent and the instant the last one is received - every implementation shall write to stdout a single number,
T, described above - every implementation shall be provided in a separated folder with a significant name
- every implementation shall provide a
README.mdfile with (at least) the following sections:Build: instructions on how to build; after a successful build, aringexecutable should be present in a build directoryDescription: a brief description of the implementation
- every implementation has complete freedom on all other aspects not specified above
> ./ring 200000 30
465 2990 200000 30
where:
465is the time in ms to setup the ring2990is the time in ms from the first message to the last one200000is the number of nodes in the ring30is the number of trips (how many times we sent a message in the ring)
- Build
cd erling
erlc ring.erl- Run
./ring 200000 30- Build
cd exring
mix escript.build- Run
./exring 200000 30- Build
cd goring
make all- Run
./ring 200000 30- Build
cd haskring
make all- Run
./ring 200000 30- Run
cd rustring
cargo run --release -- 200000 30Needs boost::fiber and boost::context.
- Run
cd cppring
make- Build
cd benchmark
make- Run
./benchmark 10 100:300:100 1000:3000:1000