https://github.com/grakshith/crust
CS 263 project
https://github.com/grakshith/crust
Last synced: 9 months ago
JSON representation
CS 263 project
- Host: GitHub
- URL: https://github.com/grakshith/crust
- Owner: grakshith
- License: mit
- Created: 2020-04-14T02:53:39.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-06-09T05:10:44.000Z (about 6 years ago)
- Last Synced: 2025-10-23T05:43:38.373Z (9 months ago)
- Language: Assembly
- Size: 2.24 MB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# crust
## About
A small project to compare different features of Rust and C++ as a systems programming language.
## Instructions to Compile
### Rust installation
`rustc` is the compiler that is used. To install Rust on a Unix-like OS run the following command
```bash
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
```
For all the ways to install rust please visit this site: https://www.rust-lang.org/tools/install
### Code Compilation
#### Rust
All the Rust implementations are present in the directory [src/rs/src](https://github.com/grakshith/crust/tree/master/src/rs/src). Run the following instructions to go to that directory from the root of this project and compile all the Rust codes
```bash
cd src/rs/src
./compile.sh
```
This will compile all the Rust src and put the executables in the directory [src/rs/bin](https://github.com/grakshith/crust/tree/master/src/rs/bin) (path wrt project root)
```bash
cd ../bin
```
#### C++
All the C++ src files are present in the directory [src/cxx](https://github.com/grakshith/crust/tree/master/src/cxx). Run the following instructions to go to that directory from the root of this project and compile all the C++ codes
```bash
cd src/cxx
make
```
This will compile all the C++ src and put the executables in the directory src/cxx/bin (path wrt project root)
```bash
cd bin
```
## Instructions to benchmark
The [benchmark.py](https://github.com/grakshith/crust/tree/master/src/benchmark.py) in the `src` directory, contains the Python script which runs the all the executables. It uses the `config.json` as a guide to run which executables. After it runs it stores the output in the file called `results-{date}_{time}.json` in the directory [src/results](https://github.com/grakshith/crust/tree/master/src/results) (path wrt to project root).
### config.json
Edit the [config.json](https://github.com/grakshith/crust/tree/master/src/config.json) inside the src folder as follows.
To add an executable to compare with the others add an object like the following
```JavaScript
{
"binaries": [
{...},
{
"name": "An easy name to identify in the result.json",
"command": "Location of the binary along with its argument like how you would run from the terminal",
"iterations": 10 //An integer value specifying the number of times the code will be run
},
{
"name": "Linked list in Rust",
"command": "rs/bin/linked_list",
"iterations": 100
}
{...}
]
}
```
### Running the benchmark
We used Python 3.5 version of Python. To run the benchmark simply run the following command
```bash
python benchmark.py
```
After executing all the binaries the result will be stored in the `results-{date}_{time}.json` file. It has the following structure
```JavaScript
{
"results": [
{...},
{
"name": "The same you used in config.json",
"iterations": 100, // An integer specifying the number of times the code was run
"time_unit": "us", // Represents micro-seconds
"mean": 1234.56, // mean time taken by the executable across all the runs
"median": 1234.56, // the median of all the times taken by the executable
"stddiv": 123.56 // the standard deviation of execution times across all the runs
}
{...}
]
}
```
### Requirements
Tested on a new anaconda environment with Python 3.5, the only required package was `psutil`. Run the following command to install this requirement
```bash
pip install -r requirements.txt
# or simply
pip install psutil
```
If it shows any other dependency required just install them using `pip`