diff --git a/code/tests/meson.build b/code/tests/meson.build index c3b9e87..cd22f08 100644 --- a/code/tests/meson.build +++ b/code/tests/meson.build @@ -17,6 +17,7 @@ if get_option('with_test').enabled() dependencies: [ dependency('fossil-test'), dependency('fossil-mock'), + dependency('fossil-mark'), fossil_tofu_dep]) test('Pizza Test Run', pizza) diff --git a/code/tests/test_arrayof.c b/code/tests/test_arrayof.c index 95eee20..78772f4 100644 --- a/code/tests/test_arrayof.c +++ b/code/tests/test_arrayof.c @@ -12,6 +12,7 @@ * ----------------------------------------------------------------------------- */ #include +#include #include #include "fossil/tofu/framework.h" @@ -81,6 +82,19 @@ FOSSIL_TEST(test_fossil_tofu_arrayof_clear) { fossil_tofu_arrayof_erase(&array); } +// benchmarking cases to capture the true +// performence based on current structures +// implmentation. + +FOSSIL_TEST(stress_test_array) { + fossil_tofu_arrayof_t array = fossil_tofu_arrayof_create("int", 0); + for (int i = 0; i < 1000000; i++) { + fossil_tofu_t tofu = fossil_tofu_create("int", "10"); + fossil_tofu_arrayof_add(&array, tofu); + } + fossil_tofu_arrayof_erase(&array); +} + // * * * * * * * * * * * * * * * * * * * * * * * * // * Fossil Logic Test Pool // * * * * * * * * * * * * * * * * * * * * * * * * @@ -92,4 +106,7 @@ FOSSIL_TEST_GROUP(c_arrayof_structure_tests) { ADD_TEST(test_fossil_tofu_arrayof_size); ADD_TEST(test_fossil_tofu_arrayof_is_empty); ADD_TEST(test_fossil_tofu_arrayof_clear); + + // Benchmarking + ADD_TEST(stress_test_array); } // end of tests diff --git a/code/tests/test_doublylist.c b/code/tests/test_doublylist.c index 0b4663b..07c2030 100644 --- a/code/tests/test_doublylist.c +++ b/code/tests/test_doublylist.c @@ -12,6 +12,7 @@ * ----------------------------------------------------------------------------- */ #include +#include #include #include "fossil/tofu/framework.h" @@ -133,6 +134,26 @@ FOSSIL_TEST(test_dlist_reverse_backward) { ASSUME_ITS_EQUAL_I32(42, retrievedElement->value.int_val); } +// benchmarking cases to capture the true +// performence based on current structures +// implmentation. + +FOSSIL_TEST(stress_test_dlist) { + // Create an element + fossil_tofu_t element = fossil_tofu_create("int", "42"); + + // Start the benchmark + TEST_BENCHMARK(); + + // Insert the element + fossil_dlist_insert(mock_dlist, element); + + // Stop the benchmark + TEST_DURATION_SEC(TEST_CURRENT_TIME(), 1.0); + + fossil_tofu_erase(&element); +} + // * * * * * * * * * * * * * * * * * * * * * * * * // * Fossil Logic Test Pool // * * * * * * * * * * * * * * * * * * * * * * * * @@ -143,4 +164,6 @@ FOSSIL_TEST_GROUP(c_dlist_structure_tests) { ADD_TESTF(test_dlist_remove, struct_dlist_fixture); ADD_TESTF(test_dlist_reverse_forward, struct_dlist_fixture); ADD_TESTF(test_dlist_reverse_backward, struct_dlist_fixture); + + ADD_TESTF(stress_test_dlist, struct_dlist_fixture); } // end of tests diff --git a/code/tests/test_dqueue.c b/code/tests/test_dqueue.c index 571bbb7..e4df98b 100644 --- a/code/tests/test_dqueue.c +++ b/code/tests/test_dqueue.c @@ -12,7 +12,9 @@ * ----------------------------------------------------------------------------- */ #include +#include #include + #include // * * * * * * * * * * * * * * * * * * * * * * * * @@ -125,6 +127,27 @@ FOSSIL_TEST(test_dqueue_not_empty_and_is_empty) { ASSUME_ITS_TRUE(fossil_dqueue_is_empty(mock_dqueue)); } +// benchmarking cases to capture the true +// performence based on current structures +// implmentation. + +FOSSIL_TEST(stress_test_dqueue) { + // Create an element + fossil_tofu_t element = fossil_tofu_create("int", "42"); + + // Start the benchmark + TEST_BENCHMARK(); + + for (size_t i = 0; i < 1000000; i++) { + fossil_dqueue_insert(mock_dqueue, element); + } + + // Stop the benchmark + TEST_DURATION_SEC(TEST_CURRENT_TIME(), 1.0); + + fossil_tofu_erase(&element); +} + // * * * * * * * * * * * * * * * * * * * * * * * * // * Fossil Logic Test Pool // * * * * * * * * * * * * * * * * * * * * * * * * @@ -134,4 +157,7 @@ FOSSIL_TEST_GROUP(c_dqueue_structure_tests) { ADD_TESTF(test_dqueue_remove, struct_dqueue_fixture); //ADD_TESTF(test_dqueue_getter_and_setter, struct_dqueue_fixture); ADD_TESTF(test_dqueue_not_empty_and_is_empty, struct_dqueue_fixture); + + // Benchmarking cases + ADD_TESTF(stress_test_dqueue, struct_dqueue_fixture); } // end of tests diff --git a/code/tests/test_forwardlist.c b/code/tests/test_forwardlist.c index e3c9280..d508abd 100644 --- a/code/tests/test_forwardlist.c +++ b/code/tests/test_forwardlist.c @@ -12,6 +12,7 @@ * ----------------------------------------------------------------------------- */ #include +#include #include #include "fossil/tofu/framework.h" @@ -136,6 +137,28 @@ FOSSIL_TEST(test_flist_reverse_backward) { ASSUME_ITS_EQUAL_I32(42, retrievedElement->value.int_val); } +// benchmarking cases to capture the true +// performence based on current structures +// implmentation. + +FOSSIL_TEST(stress_test_flist) { + // Create an element + fossil_tofu_t element = fossil_tofu_create("int", "42"); + + // Start the benchmark + TEST_BENCHMARK(); + + for (size_t i = 0; i < 1000000; i++) { + fossil_flist_insert(mock_flist, element); + fossil_flist_remove(mock_flist, &element); + } + + // Stop the benchmark + TEST_DURATION_SEC(TEST_CURRENT_TIME(), 1.0); + + fossil_tofu_erase(&element); +} + // * * * * * * * * * * * * * * * * * * * * * * * * // * Fossil Logic Test Pool // * * * * * * * * * * * * * * * * * * * * * * * * @@ -145,4 +168,7 @@ FOSSIL_TEST_GROUP(c_flist_structure_tests) { ADD_TESTF(test_flist_remove, struct_flist_fixture); ADD_TESTF(test_flist_reverse_forward, struct_flist_fixture); ADD_TESTF(test_flist_reverse_backward, struct_flist_fixture); + + // Benchmarking cases + ADD_TESTF(stress_test_flist, struct_flist_fixture); } // end of tests diff --git a/code/tests/test_mapof.c b/code/tests/test_mapof.c index db92d3a..6e89434 100644 --- a/code/tests/test_mapof.c +++ b/code/tests/test_mapof.c @@ -12,6 +12,7 @@ * ----------------------------------------------------------------------------- */ #include +#include #include #include "fossil/tofu/framework.h" @@ -101,6 +102,32 @@ FOSSIL_TEST(test_fossil_tofu_mapof_clear) { fossil_tofu_mapof_erase(&map); } +// benchmarking cases to capture the true +// performence based on current structures +// implmentation. + +FOSSIL_TEST(stress_test_map) { + // Create a map object + fossil_tofu_mapof_t map = fossil_tofu_mapof_create("int"); + + // Start the benchmark + TEST_BENCHMARK(); + + // Perform some operations + for (size_t i = 0; i < 1000000; i++) { + fossil_tofu_t key = fossil_tofu_create("int", "1"); + fossil_tofu_t value = fossil_tofu_create("int", "100"); + fossil_tofu_mapof_add(&map, key, value); + fossil_tofu_mapof_remove(&map, key); + } + + // Stop the benchmark + TEST_DURATION_SEC(TEST_CURRENT_TIME(), 1.0); + + // Erase the map object + fossil_tofu_mapof_erase(&map); +} + // * * * * * * * * * * * * * * * * * * * * * * * * // * Fossil Logic Test Pool // * * * * * * * * * * * * * * * * * * * * * * * * @@ -113,4 +140,7 @@ FOSSIL_TEST_GROUP(c_mapof_structure_tests) { ADD_TEST(test_fossil_tofu_mapof_size); ADD_TEST(test_fossil_tofu_mapof_is_empty); ADD_TEST(test_fossil_tofu_mapof_clear); + + // Benchmarking + ADD_TEST(stress_test_map); } // end of tests diff --git a/code/tests/test_pqueue.c b/code/tests/test_pqueue.c index cf97f64..c24f1fb 100644 --- a/code/tests/test_pqueue.c +++ b/code/tests/test_pqueue.c @@ -12,6 +12,7 @@ * ----------------------------------------------------------------------------- */ #include +#include #include #include "fossil/tofu/framework.h" @@ -96,6 +97,28 @@ FOSSIL_TEST(test_pqueue_not_empty_and_is_empty) { ASSUME_ITS_TRUE(fossil_pqueue_remove(mock_pqueue, &removedElement, removedPriority)); } +// benchmarking cases to capture the true +// performence based on current structures +// implmentation. + +FOSSIL_TEST(stress_test_pqueue) { + // Create an element + fossil_tofu_t element = fossil_tofu_create("int", "42"); + + // Start the benchmark + TEST_BENCHMARK(); + + for (size_t i = 0; i < 1000000; i++) { + fossil_pqueue_insert(mock_pqueue, element, 2); + fossil_pqueue_remove(mock_pqueue, &element, 2); + } + + // Stop the benchmark + TEST_DURATION_SEC(TEST_CURRENT_TIME(), 1.0); + + fossil_tofu_erase(&element); +} + // * * * * * * * * * * * * * * * * * * * * * * * * // * Fossil Logic Test Pool // * * * * * * * * * * * * * * * * * * * * * * * * @@ -105,4 +128,7 @@ FOSSIL_TEST_GROUP(c_pqueue_structure_tests) { ADD_TESTF(test_pqueue_insert_and_size, struct_pqueue_fixture); ADD_TESTF(test_pqueue_remove, struct_pqueue_fixture); ADD_TESTF(test_pqueue_not_empty_and_is_empty, struct_pqueue_fixture); + + // Benchmarking + ADD_TESTF(stress_test_pqueue, struct_pqueue_fixture); } // end of tests diff --git a/code/tests/test_queue.c b/code/tests/test_queue.c index fcb28f6..f9678c6 100644 --- a/code/tests/test_queue.c +++ b/code/tests/test_queue.c @@ -12,6 +12,7 @@ * ----------------------------------------------------------------------------- */ #include +#include #include #include "fossil/tofu/framework.h" @@ -104,6 +105,28 @@ FOSSIL_TEST(test_queue_not_empty_and_is_empty) { fossil_tofu_erase(&element); } +// benchmarking cases to capture the true +// performence based on current structures +// implmentation. + +FOSSIL_TEST(stress_test_queue) { + // Create an element + fossil_tofu_t element = fossil_tofu_create("int", "42"); + + // Start the benchmark + TEST_BENCHMARK(); + + for (size_t i = 0; i < 1000000; i++) { + fossil_queue_insert(mock_queue, element); + fossil_queue_remove(mock_queue, &element); + } + + // Stop the benchmark + TEST_DURATION_SEC(TEST_CURRENT_TIME(), 1.0); + + fossil_tofu_erase(&element); +} + // * * * * * * * * * * * * * * * * * * * * * * * * // * Fossil Logic Test Pool // * * * * * * * * * * * * * * * * * * * * * * * * @@ -113,4 +136,7 @@ FOSSIL_TEST_GROUP(c_structure_tests) { ADD_TESTF(test_queue_insert_and_size, struct_queue_fixture); ADD_TESTF(test_queue_remove, struct_queue_fixture); ADD_TESTF(test_queue_not_empty_and_is_empty, struct_queue_fixture); + + // Benchmarking + ADD_TESTF(stress_test_queue, struct_queue_fixture); } // end of tests diff --git a/code/tests/test_setof.c b/code/tests/test_setof.c index 4d6ac3c..489b006 100644 --- a/code/tests/test_setof.c +++ b/code/tests/test_setof.c @@ -12,6 +12,7 @@ * ----------------------------------------------------------------------------- */ #include +#include #include #include "fossil/tofu/framework.h" @@ -107,6 +108,28 @@ FOSSIL_TEST(test_set_contains) { fossil_tofu_erase(&element3); } +// benchmarking cases to capture the true +// performence based on current structures +// implmentation. + +FOSSIL_TEST(stress_test_set) { + // Create an element + fossil_tofu_t element = fossil_tofu_create("int", "42"); + + // Start the benchmark + TEST_BENCHMARK(); + + for (size_t i = 0; i < 1000000; i++) { + fossil_set_insert(mock_set, element); + fossil_set_remove(mock_set, element); + } + + // Stop the benchmark + TEST_DURATION_SEC(TEST_CURRENT_TIME(), 1.0); + + fossil_tofu_erase(&element); +} + // * * * * * * * * * * * * * * * * * * * * * * * * // * Fossil Logic Test Pool // * * * * * * * * * * * * * * * * * * * * * * * * @@ -116,4 +139,7 @@ FOSSIL_TEST_GROUP(c_setof_structure_tests) { ADD_TESTF(test_set_insert_and_size, struct_set_fixture); ADD_TESTF(test_set_remove, struct_set_fixture); ADD_TESTF(test_set_contains, struct_set_fixture); + + // Benchmarking + ADD_TESTF(stress_test_set, struct_set_fixture); } // end of tests diff --git a/code/tests/test_stack.c b/code/tests/test_stack.c index ac4d34e..03bf339 100644 --- a/code/tests/test_stack.c +++ b/code/tests/test_stack.c @@ -12,6 +12,7 @@ * ----------------------------------------------------------------------------- */ #include +#include #include #include "fossil/tofu/framework.h" @@ -91,6 +92,28 @@ FOSSIL_TEST(test_stack_remove) { fossil_tofu_erase(&element3); } +// benchmarking cases to capture the true +// performence based on current structures +// implmentation. + +FOSSIL_TEST(stress_test_stack) { + // Create an element + fossil_tofu_t element = fossil_tofu_create("int", "42"); + + // Start the benchmark + TEST_BENCHMARK(); + + for (size_t i = 0; i < 1000000; i++) { + fossil_stack_insert(mock_stack, element); + fossil_stack_remove(mock_stack, &element); + } + + // Stop the benchmark + TEST_DURATION_SEC(TEST_CURRENT_TIME(), 1.0); + + fossil_tofu_erase(&element); +} + // * * * * * * * * * * * * * * * * * * * * * * * * // * Fossil Logic Test Pool // * * * * * * * * * * * * * * * * * * * * * * * * @@ -100,4 +123,7 @@ FOSSIL_TEST_GROUP(c_stack_structure_tests) { ADD_TESTF(test_stack_create_and_erase, struct_stack_fixture); ADD_TESTF(test_stack_insert_and_size, struct_stack_fixture); ADD_TESTF(test_stack_remove, struct_stack_fixture); + + // Stack Benchmark + ADD_TESTF(stress_test_stack, struct_stack_fixture); } // end of tests diff --git a/code/tests/test_tofu.c b/code/tests/test_tofu.c index 36e8908..287b84c 100644 --- a/code/tests/test_tofu.c +++ b/code/tests/test_tofu.c @@ -12,6 +12,7 @@ * ----------------------------------------------------------------------------- */ #include +#include #include #include "fossil/tofu/framework.h" @@ -277,6 +278,30 @@ FOSSIL_TEST(test_fossil_tofu_create_invalid) { ASSUME_ITS_EQUAL_I32(FOSSIL_TOFU_TYPE_GHOST, tofu_invalid_value.type); } +// benchmarking cases to capture the true +// performence based on current structures +// implmentation. + +FOSSIL_TEST(stress_test_tofu_type) { + // Create a tofu object + fossil_tofu_t tofu = fossil_tofu_create("int", "100"); + + // Start the benchmark + TEST_BENCHMARK(); + + // Perform some operations + for (size_t i = 0; i < 1000000; i++) { + fossil_tofu_t tofu_copy = fossil_tofu_copy(tofu); + fossil_tofu_erase(&tofu_copy); + } + + // Stop the benchmark + TEST_DURATION_SEC(TEST_CURRENT_TIME(), 1.0); + + // Erase the tofu object + fossil_tofu_erase(&tofu); +} + // * * * * * * * * * * * * * * * * * * * * * * * * // * Fossil Logic Test Pool // * * * * * * * * * * * * * * * * * * * * * * * * @@ -303,4 +328,7 @@ FOSSIL_TEST_GROUP(c_generic_tofu_tests) { // Verification checks fixture ADD_TEST(test_fossil_verification_checks); ADD_TEST(test_fossil_tofu_create_invalid); + + // Benchmarking cases + ADD_TEST(stress_test_tofu_type); } // end of tests diff --git a/code/tests/test_vector.c b/code/tests/test_vector.c index e3359bf..d6b734e 100644 --- a/code/tests/test_vector.c +++ b/code/tests/test_vector.c @@ -12,6 +12,7 @@ * ----------------------------------------------------------------------------- */ #include +#include #include #include "fossil/tofu/framework.h" @@ -88,6 +89,73 @@ FOSSIL_TEST(test_vector_search) { fossil_tofu_erase(&element3); } +FOSSIL_TEST(test_vector_reverse) { + // Push back some elements + fossil_tofu_t element1 = fossil_tofu_create("int", "42"); + fossil_tofu_t element2 = fossil_tofu_create("int", "10"); + fossil_tofu_t element3 = fossil_tofu_create("int", "5"); + + fossil_vector_push_back(mock_vector, element1); + fossil_vector_push_back(mock_vector, element2); + fossil_vector_push_back(mock_vector, element3); + + // Reverse the vector + fossil_vector_reverse(mock_vector); + + // Check if the elements are reversed + ASSUME_ITS_EQUAL_I32(5, mock_vector->data[0].value.int_val); + ASSUME_ITS_EQUAL_I32(10, mock_vector->data[1].value.int_val); + ASSUME_ITS_EQUAL_I32(42, mock_vector->data[2].value.int_val); + + fossil_tofu_erase(&element1); + fossil_tofu_erase(&element2); + fossil_tofu_erase(&element3); +} + +FOSSIL_TEST(test_vector_size) { + // Push back some elements + fossil_tofu_t element1 = fossil_tofu_create("int", "42"); + fossil_tofu_t element2 = fossil_tofu_create("int", "10"); + fossil_tofu_t element3 = fossil_tofu_create("int", "5"); + + fossil_vector_push_back(mock_vector, element1); + fossil_vector_push_back(mock_vector, element2); + fossil_vector_push_back(mock_vector, element3); + + // Check the size of the vector + ASSUME_ITS_EQUAL_U32(3, fossil_vector_size(mock_vector)); + + fossil_tofu_erase(&element1); + fossil_tofu_erase(&element2); + fossil_tofu_erase(&element3); +} + +// benchmarking cases to capture the true +// performence based on current structures +// implmentation. + +FOSSIL_TEST(stress_test_vector_usage) { + // setup nodes + fossil_tofu_t element1 = fossil_tofu_create("int", "42"); + fossil_tofu_t element2 = fossil_tofu_create("int", "10"); + fossil_tofu_t element3 = fossil_tofu_create("int", "5"); + + // Start the benchmark + TEST_BENCHMARK(); + + for (size_t i = 0; i < 1000000; i++) { + fossil_vector_push_back(mock_vector, element1); + fossil_vector_push_back(mock_vector, element2); + fossil_vector_push_back(mock_vector, element3); + } + + // Stop the benchmark + TEST_DURATION_SEC(TEST_CURRENT_TIME(), 1.0); + + // Check if the elements are added correctly + ASSUME_ITS_EQUAL_I32(3000000, mock_vector->size); +} + // * * * * * * * * * * * * * * * * * * * * * * * * // * Fossil Logic Test Pool // * * * * * * * * * * * * * * * * * * * * * * * * @@ -96,4 +164,9 @@ FOSSIL_TEST_GROUP(c_vector_structure_tests) { // Vector Fixture ADD_TESTF(test_vector_push_back, struct_vect_fixture); ADD_TESTF(test_vector_search, struct_vect_fixture); + ADD_TESTF(test_vector_reverse, struct_vect_fixture); + ADD_TESTF(test_vector_size, struct_vect_fixture); + + // Vector Benchmark + ADD_TESTF(stress_test_vector_usage, struct_vect_fixture); } // end of tests