Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,15 @@ docs/_build/

# Pyenv
.python-version


# Auto-generated by autoignore:
# --------------- #
flamegraph.svg
perf.data
perf.data.old
redoxql-m1.zip
tests/flamegraph.svg
tests/perf.data
tests/perf.data.old
# ----------------#
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ harness = false
name = "query_benchmarks"
harness = false

[profile.bench]
debug = true

# Speed improvements
[profile.release]
lto = "fat"
Expand Down
53 changes: 46 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ The src (`./src`) directory is where the Rust code goes. This gets called by the

## Testing

#### Rust testing
### Rust testing

```
cargo test
```
Expand All @@ -130,35 +131,73 @@ Here is what the correct output should look like. You should see multiple tests

![image](https://github.com/user-attachments/assets/b6aee0b5-571f-4450-9381-296efc5e2f73)

Rust tests are located in each Rust file and can be found in `./src`
#### Unit Tests

Rust unit tests are located in each Rust file and can be found in `./src`

#### Integration Tests

#### Python testing
The integration tests are located at `./tests` and are also run with `cargo test`

### Python testing
```
pytest
```

Python tests are located in a seperate directory called `tests` located in `./python`
Python tests are located in a separate directory called `tests` located in `./python`

## Rust Docs

Rust has a way of making docs from the source code. Run `cargo doc` and view the produced HTML page in your browser. Adding comments to yor code starting with `///` will be put into these docs.

## Speed Analysis

#### Using maturin in release mode
### Using flamegraph to benchmark

You may need to install flamegraph with `cargo install flamegraph`

```sh
cargo flamegraph --test update_tests
```

```sh
# Open the svg (It's nice to view in a browser)
firefox flamegraph.svg
```

Preview:

![image](https://github.com/user-attachments/assets/ac866062-79f2-45e0-84ae-c81dceef68cc)

### Running cargo benchmarks

This will take a long time but you can run benchmarks separately.

```sh
cargo bench
```

You can use `cargo bench` to see if your changes significantly affect performance.

![image](https://github.com/user-attachments/assets/367e1f7a-dd85-46ed-998a-939f95a1b561)

Often small changes can happen randomly. Like this has no change in the code.
Try to run the bench as the only thing running on the system.

### Using maturin in release mode

![perf_chart](https://github.com/user-attachments/assets/31b18374-11b6-42fd-8405-5f32a751804f)
![tests_chart](https://github.com/user-attachments/assets/8e638ec0-12f7-461f-b1e6-7823d98004cf)

Data for both graphs can be found [here](./python/benchmarks/speedtests.py)

#### Scaling of Insert Operation
### Scaling of Insert Operation

![scaling](https://github.com/user-attachments/assets/22cff07d-d7b0-4502-b559-635a22e38c77)

![update_scale](https://github.com/user-attachments/assets/e65ee6c3-7256-4cf1-8432-369cd6658eaf)

#### Using release build settings
### Using release build settings

With compiler options
```
Expand Down
16 changes: 16 additions & 0 deletions tests/update_tests.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
use redoxql::database::RDatabase;
use redoxql::query::RQuery;

#[test]
fn thousands_of_updates_test() {
let mut db = RDatabase::new();
let t = db.create_table(String::from("Grades"), 3, 0);
let mut q = RQuery::new(t);

q.insert(vec![0, 2, 3]);

for x in 0..1_000_000 {
let res = q.update(0, vec![Some(x), None, None]);
assert!(res);
}
}