This is a collection of programs written in various languages to perform the exact same tasks as a demonstration of both the syntactic differences between these languages as well as the run-time speeds of their respective compiled (or interpreted) outputs.
There are two ways to run the code examples:
- Make sure you have the compilers/interpreters for these languages installed correctly.
- Clone this repo (
git clone https://github.com/luke5542/LanguageComparison
). - Change directories to the example you want to run (e.g.
cd sieve-of-eratosthenes
) - Run the
make runall
to run all tests in that directory
- Ensure you have docker installed
- Pull the latest prebuilt docker image using
docker pull quay.io/passmcr/languagecomparison
- To run the tests, execute the container directly:
docker run quay.io/passmcr/languagecomparison
- To view/edit the code yourself, drop into a docker shell using
docker run -it quay.io/passmcr/languagecomparison /bin/bash
Note: Running docker on Windows or MacOSX (currently) requires the use of a boot2docker VM or something similar. This obviously has an overhead associated with it - however as long as the tests are all run in a container, the results should be roughly consistent with those obtained outside of a container.
A HTML page can be generated in order to visualise the various run timings.
- Run the script in
output
usingpython3 ./generate_data.py -b
. - This compiles and runs all examples.
- A HTML page (
benchmark.html
) with the results is generated and placed in the root directory of the project. - For the sieve-of-eratosthenes examples, the
-s
flag can be used to set the maximum size of the sieve.