Skip to content

Commit

Permalink
Updated benchmarks and added Makefile and demo files
Browse files Browse the repository at this point in the history
  • Loading branch information
FLAK-ZOSO committed Dec 21, 2023
1 parent 779e0c8 commit 489fedb
Show file tree
Hide file tree
Showing 10 changed files with 125 additions and 5 deletions.
47 changes: 45 additions & 2 deletions Benchmarks.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ The following benchmarks were run on...
- Windows 11 Pro `22H2`
- 64-bit OS, x64-based processor

From version `1.0.0` the benchmarks were run on...

- Acer Aspire E5-573G
- Intel core `i7-5500U` CPU `3.00GHz`
- `8GB` RAM
- Ubuntu 22.04.3 LTS x86_64

## v`0.1.0`

### `sista.exe` I - 7/12/2022
Expand Down Expand Up @@ -114,7 +121,7 @@ The following test was run with...

- `50 x 50` Field size (`2500` cells)
- `1000` = `1000` iterations
- `50` `Pawn` instances (allocated on heap with `new`)
- `6` `Pawn` instances (allocated on heap with `new`)
- `10 milliseconds` per frame (`100 FPS`)

...and the following numeric results were obtained...
Expand All @@ -129,4 +136,40 @@ The following test was run with...

- The refresh is smooth (actually there's no refresh)
- No flickering at all (there's no more refresh)
- Not a single `Pawn` movement is snappy (due to the fact that they're at the same x coordinate)
- Not a single `Pawn` movement is snappy (due to the fact that they're at the same x coordinate)

## v`1.0.0`

### [`header-test`](https://github.com/FLAK-ZOSO/Sista/blob/main/demo/header-test.cpp) - 21/12/2023

The following test was run with...

- `50 x 50` Field size (`2500` cells)
- `50` `Pawn` instances (allocated on heap with `new`)
- `10 milliseconds` per frame (`100 FPS`)
- `1000` = `1000` iterations

...and the following numeric results were obtained...

- `11"` (11 seconds) elapsed time
- `1000 x 0.010` = `10"` slept time
- `1000 x 2500 / 11` = `227272` cells per second
- `header-test` max memory usage: `131KBytes`
- `header-test` max CPU usage: `2.17%` (according to System Monitor)

### `sista` VI - 21/12/2023

The following test was run with...

- `50 x 50` Field size (`2500` cells)
- `6` `Pawn` instances (allocated on heap with `new`)
- `10 milliseconds` per frame (`100 FPS`)
- `1000` = `1000` iterations

...and the following numeric results were obtained...

- `11"` (11 seconds) elapsed time
- `1000 x 0.010` = `10"` slept time
- `1000 x 2500 / 11` = `227272` cells per second
- `sista` max memory usage: `262KBytes`
- `sista` max CPU usage: `0.26%` (according to System Monitor)
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Makefile for sista.cpp
IMPLEMENTATIONS = include/sista/ANSI-Settings.cpp include/sista/border.cpp include/sista/coordinates.cpp include/sista/cursor.cpp include/sista/field.cpp include/sista/pawn.cpp

all:
g++ -std=c++17 -Wall -g -c $(IMPLEMENTATIONS)
g++ -std=c++17 -Wall -g -c sista.cpp
g++ -std=c++17 -Wall -g -o sista sista.o ANSI-Settings.o border.o coordinates.o cursor.o pawn.o field.o
rm -f *.o
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# `Sista`

`Sista` is a *lightweight*, *fast*, and *easy-to-use* *OOP* library for making terminal games in `C++`.
`Sista` is a *header-only* library that provides a set of classes and functions to make it easier to create terminal games in `C++`.
`Sista` provides a set of classes and functions to make terminal games in `C++` easier.

Inspired by their [`Forsiktig`](https://github.com/Lioydiano/Forsiktig)'s [`variables.hpp`](https://github.com/Lioydiano/Forsiktig/blob/main/variables.hpp) header, @FLAK-ZOSO decided to make a library to prevent others from having to reinvent the wheel every time they wanted to make a terminal game.

Expand Down
6 changes: 6 additions & 0 deletions ReleaseNotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,3 +175,9 @@ void addPrintPawn(Pawn* pawn) { // Add a pawn to the matrix and print it
pawn->print(); // Print the pawn
}
```
## v`1.0.0`
- Divided Sista in `.hpp` headers and `.cpp` sources
This should make it possible to use Sista in projects with multiple source files.
7 changes: 7 additions & 0 deletions demo/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
IMPLEMENTATIONS = ../include/sista/ANSI-Settings.cpp ../include/sista/border.cpp ../include/sista/coordinates.cpp ../include/sista/cursor.cpp ../include/sista/field.cpp ../include/sista/pawn.cpp

all:
g++ -std=c++17 -Wall -g -c $(IMPLEMENTATIONS)
g++ -std=c++17 -Wall -g -c header-test.cpp
g++ -std=c++17 -Wall -g -o header-test header-test.o ANSI-Settings.o border.o coordinates.o cursor.o pawn.o field.o
rm -f *.o
Binary file added demo/header-test
Binary file not shown.
56 changes: 56 additions & 0 deletions demo/header-test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// make
#include "../include/sista/sista.hpp"
#include <chrono>
#include <thread>


ANSI::Settings default_settings(
ANSI::ForegroundColor::F_WHITE,
ANSI::BackgroundColor::B_BLACK,
ANSI::Attribute::RESET
);
sista::Border border(
'#', ANSI::Settings(
ANSI::ForegroundColor::F_WHITE,
ANSI::BackgroundColor::B_BLACK,
ANSI::Attribute::BLINK
)
);


int main() {
sista::SwappableField field(50, 50);
std::vector<sista::Pawn*> pawns;
for (int i = 0; i < 50; i++) {
pawns.push_back(
new sista::Pawn(
'X', {
rand() % 50,
rand() % 50
}, default_settings
)
);
field.addPawn(pawns[i]);
}
field.print(border);

std::vector<sista::Coordinates> coords(pawns.size());
for (int i = 0; i < 1000; i++) {
for (int k = 0; k < pawns.size(); k++) {
coords[k] = field.movingByCoordinates(
pawns[k], rand() % 3 - 1, rand() % 3 - 1, PACMAN_EFFECT
);
}
try {
for (int k = 0; k < pawns.size(); k++) {
field.movePawn(pawns[k], coords[k]);
}
} catch (std::invalid_argument& e) {
for (int k = 0; k < pawns.size(); k++) {
field.addPawnToSwap(pawns[k], coords[k]);
}
field.applySwaps();
}
std::this_thread::sleep_for(std::chrono::milliseconds(10));
}
}
2 changes: 1 addition & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

``Sista`` is a *lightweight*, *fast*, and *easy-to-use* *OOP* library for making terminal games in ``C++``.

``Sista`` is a *header-only* library that provides a set of classes and functions to make it easier to create terminal games in ``C++``.
``Sista`` provides a set of classes and functions to make terminal games in ``C++`` easier.

Inspired by their `Forsiktig <https://github.com/Lioydiano/Forsiktig>`_ 's `variables.hpp <https://github.com/Lioydiano/Forsiktig/blob/main/variables.hpp>`_ header, `FLAK-ZOSO <https://flak-zoso.github.io>`_ decided to make a library to prevent others from having to reinvent the wheel every time they wanted to make a terminal game.

Expand Down
Binary file added sista
Binary file not shown.
2 changes: 1 addition & 1 deletion sista.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// g++ sista.cpp -o sista -std=c++17 -Wall
// make
#include <chrono>
#include <thread>
#include "include/sista/sista.hpp"
Expand Down

0 comments on commit 489fedb

Please sign in to comment.