Commit f7492c7d authored by Filip Vincze's avatar Filip Vincze
Browse files

add measuring README, adjust benchmarks script

parent 46ec5381
Loading
Loading
Loading
Loading

measurements/README.md

0 → 100644
+28 −0
Original line number Diff line number Diff line
## Performacne Measurements
Here you can find measurement tools for the UI module.

## Build
Build the app with ```-DCMAKE_BUILD_TYPE=Release``` (please read the root README).

## Benchmarks

**Script**

After building the app, copy files ```benchmarks.py``` and ```benchmarks.sh``` to the ```dist``` directory. Run the ```benchmarks.sh```
script.

The script will run Benchmarks 1 and 2 with the parameters ```BUTTON_COUNTS, TEXT_SIZES, BUFFER_SIZES``` for a ```TIME``` of 10 seconds, defined in the script. 

Afterward, the python script will create ```benchmark1.csv``` and ```benchmark2.csv```. Containing the FPS measurements.

**Manual**

Build the app as previously mentioned, then run the binary with the following arguments:

- benchmark - Specifies which benchmark to run (1 or 2).
- duration - Duration of the test, after which the app will quit. If it is set to 0 the program will not quit.
- button\_count - Specifies the number of buttons to instantiate (used for benchmark 1).
- text\_size - Specifies how many letters will be generated for the text (used for benchmark 2).
- buffer\_size - Specifies the maximum size of a text Buffer, used for splitting the text into multiple Buffers (for benchmark 2).

Afterwards, the output will be written to ```stdout```.
+26 −20
Original line number Diff line number Diff line
@@ -8,7 +8,9 @@ def process_log_file(log_file_path):
    if not lines:
        return

    data = {}
    benchmark1_data = []

    benchmark2_data = {}

    for line in lines:
        if not line.strip():
@@ -19,26 +21,30 @@ def process_log_file(log_file_path):
        if len(parts) == 2:
            button_count = parts[0]
            average_fps = parts[1]
            with open('benchmark1.csv', mode='w', newline='') as csv_file_2_params:
                writer_2_params = csv.writer(csv_file_2_params)
                writer_2_params.writerow(['Button Count', 'Average Fps'])
                writer_2_params.writerow([button_count, average_fps])
            benchmark1_data.append([button_count, average_fps])

        elif len(parts) == 3:
            text_size = int(parts[0])
            buffer_size = int(parts[1])
            average_fps = float(parts[2])

            if text_size not in data:
                data[text_size] = {}
            if text_size not in benchmark2_data:
                benchmark2_data[text_size] = {}

            data[text_size][buffer_size] = average_fps
            benchmark2_data[text_size][buffer_size] = average_fps

    if benchmark1_data:
        with open('benchmark1.csv', mode='w', newline='') as csv_file_2_params:
            writer_2_params = csv.writer(csv_file_2_params)
            writer_2_params.writerow(['Button Count', 'Average Fps'])
            writer_2_params.writerows(benchmark1_data)

    if benchmark2_data:
        with open('benchmark2.csv', mode='w', newline='') as csv_file_3_params:
            writer_3_params = csv.writer(csv_file_3_params)

        text_sizes = sorted(data.keys())
        buffer_sizes = sorted({buffer_size for text_size in data.values() for buffer_size in text_size.keys()})
            text_sizes = sorted(benchmark2_data.keys())
            buffer_sizes = sorted({buffer_size for text_size in benchmark2_data.values() for buffer_size in text_size.keys()})

            header = ['Buffer Size/Text Size'] + [str(text_size) for text_size in text_sizes]
            writer_3_params.writerow(header)
@@ -46,7 +52,7 @@ def process_log_file(log_file_path):
            for buffer_size in buffer_sizes:
                row = [str(buffer_size)]
                for text_size in text_sizes:
                average_fps = data.get(text_size, {}).get(buffer_size, '')
                    average_fps = benchmark2_data.get(text_size, {}).get(buffer_size, '')
                    row.append(average_fps)
                writer_3_params.writerow(row)