## Overview The DAP Test module (`dap_test`) provides comprehensive testing framework and utilities for DAP SDK development, implementing unit testing, integration testing, performance benchmarking, and automated test execution capabilities. This module enables developers to create robust test suites, validate functionality, measure performance, and ensure code quality across all DAP components. **Based on:** `dap-sdk/test/include/dap_test.h`, `dap-sdk/test/src/dap_test.c` ## Document Structure - [[#Overview|Overview]] - [[#Module Structures|Module Structures]] - [[#dap_test_t|dap_test_t - Test Instance]] - [[#dap_test_case_t|dap_test_case_t - Test Case Definition]] - [[#dap_test_suite_t|dap_test_suite_t - Test Suite]] - [[#dap_test_result_t|dap_test_result_t - Test Results]] - [[#dap_test_benchmark_t|dap_test_benchmark_t - Performance Benchmarking]] - [[#Module Functions|Module Functions]] - [[#Test Management|Test Framework Control]] - [[#Test Execution|Test Case Execution]] - [[#Assertions|Test Assertions and Validation]] - [[#Benchmarking|Performance Testing]] - [[#Error Codes|Error Codes]] - [[#Typical Examples|Typical Examples]] ## Module Structures ### dap_test_t Core test framework instance managing test execution and configuration. ```c typedef struct dap_test { struct { char *name; // Test framework name dap_test_config_t *config; // Test configuration dap_test_suite_t **suites; // Array of test suites uint32_t suites_count; // Number of test suites dap_test_state_t state; // Current test state bool is_running; // Test execution status } pub; struct { dap_test_result_t *results; // Test execution results dap_test_logger_t *logger; // Test logging system dap_htable_t *mocks_table; // Mock objects registry dap_list_t *cleanup_handlers; // Cleanup function list uint64_t tests_run; // Total tests executed uint64_t tests_passed; // Number of passed tests uint64_t tests_failed; // Number of failed tests } priv; } dap_test_t; ``` **Public Fields:** - `name` - Test framework identifier - `config` - Configuration parameters for testing - `suites` - Array of registered test suites - `suites_count` - Number of available test suites - `state` - Current execution state - `is_running` - Flag indicating active test execution **Private Fields:** - `results` - Comprehensive test execution results - `logger` - Specialized logging for test output - `mocks_table` - Registry of mock objects for testing - `cleanup_handlers` - Automatic cleanup functions ### dap_test_case_t Individual test case definition and execution context. ```c typedef struct dap_test_case { struct { char *name; // Test case name char *description; // Test case description dap_test_case_func_t test_func; // Test function pointer dap_test_priority_t priority; // Test execution priority uint32_t timeout_ms; // Test timeout in milliseconds bool is_enabled; // Test case enabled flag dap_time_t created_time; // Test case creation time } pub; struct { dap_test_case_func_t setup_func; // Setup function (before test) dap_test_case_func_t teardown_func; // Teardown function (after test) dap_list_t *dependencies; // Test dependencies list void *test_data; // Test-specific data dap_test_result_t *result; // Test execution result uint64_t execution_count; // Number of times executed dap_time_t last_run_time; // Last execution timestamp } priv; } dap_test_case_t; ``` **Test Management:** - `name` - Unique test case identifier - `test_func` - Main test function to execute - `priority` - Execution priority for test ordering - `timeout_ms` - Maximum execution time allowed - `setup_func`/`teardown_func` - Pre/post execution hooks - `dependencies` - Required test dependencies ### dap_test_suite_t Test suite containing related test cases. ```c typedef struct dap_test_suite { struct { char *name; // Test suite name char *description; // Suite description dap_test_case_t **test_cases; // Array of test cases uint32_t test_cases_count; // Number of test cases bool is_enabled; // Suite enabled flag dap_test_suite_type_t type; // Suite type (unit, integration, etc.) } pub; struct { dap_test_case_func_t suite_setup; // Suite-wide setup function dap_test_case_func_t suite_teardown; // Suite-wide teardown function dap_test_result_t *suite_results; // Suite execution results void *suite_data; // Suite-specific context data uint64_t total_run_time_ms; // Total execution time dap_time_t last_executed; // Last suite execution time } priv; } dap_test_suite_t; ``` ### dap_test_result_t Test execution results and metrics. ```c typedef struct dap_test_result { struct { dap_test_status_t status; // Test execution status char *test_name; // Name of executed test dap_time_t start_time; // Test start timestamp dap_time_t end_time; // Test completion timestamp uint64_t execution_time_ms; // Execution time in milliseconds uint32_t assertions_total; // Total assertions made uint32_t assertions_passed; // Passed assertions count } pub; struct { uint32_t assertions_failed; // Failed assertions count char *error_message; // Error message if failed char *failure_details; // Detailed failure information dap_test_stack_trace_t *stack_trace; // Stack trace for failures void *custom_data; // Custom result data dap_list_t *log_entries; // Test execution log entries } priv; } dap_test_result_t; ``` ### dap_test_benchmark_t Performance benchmarking and profiling structure. ```c typedef struct dap_test_benchmark { struct { char *name; // Benchmark name dap_test_benchmark_func_t bench_func; // Benchmark function uint32_t iterations; // Number of iterations to run uint64_t min_time_ns; // Minimum execution time (nanoseconds) uint64_t max_time_ns; // Maximum execution time (nanoseconds) uint64_t avg_time_ns; // Average execution time (nanoseconds) bool is_completed; // Benchmark completion status } pub; struct { uint64_t *iteration_times; // Individual iteration times dap_time_t start_time; // Benchmark start time dap_time_t end_time; // Benchmark end time uint64_t total_time_ns; // Total benchmark time double std_deviation; // Time standard deviation uint64_t memory_used; // Memory usage during benchmark void *benchmark_data; // Benchmark-specific data } priv; } dap_test_benchmark_t; ``` ## Module Functions ### Test Management #### `dap_test_new()` Creates new test framework instance. ```c dap_test_t* dap_test_new(const char *a_name, dap_test_config_t *a_config); ``` **Parameters:** - `a_name` (const char*) - Test framework name - `a_config` (dap_test_config_t*) - Test configuration **Returns:** - `dap_test_t*` - New test framework instance - `NULL` - Creation failed or invalid parameters **Error Conditions:** - Returns NULL if a_name is NULL or empty - Returns NULL if memory allocation fails - Returns NULL if configuration is invalid #### `dap_test_init()` Initializes test framework with configuration. ```c int dap_test_init(dap_test_t *a_test); ``` **Parameters:** - `a_test` (dap_test_t*) - Test framework to initialize **Returns:** - `0` - Initialization successful - `-1` - Invalid test parameter - `-2` - Initialization failed #### `dap_test_suite_register()` Registers test suite with framework. ```c int dap_test_suite_register(dap_test_t *a_test, dap_test_suite_t *a_suite); ``` **Parameters:** - `a_test` (dap_test_t*) - Test framework - `a_suite` (dap_test_suite_t*) - Test suite to register **Returns:** - `0` - Suite registered successfully - `-1` - Invalid parameters - `-2` - Suite already registered - `-3` - Registration failed #### `dap_test_case_add()` Adds test case to test suite. ```c int dap_test_case_add(dap_test_suite_t *a_suite, dap_test_case_t *a_test_case); ``` **Parameters:** - `a_suite` (dap_test_suite_t*) - Target test suite - `a_test_case` (dap_test_case_t*) - Test case to add **Returns:** - `0` - Test case added successfully - `-1` - Invalid parameters - `-2` - Test case already exists - `-3` - Suite at capacity #### `dap_test_cleanup()` Cleans up test framework and frees resources. ```c void dap_test_cleanup(dap_test_t *a_test); ``` **Parameters:** - `a_test` (dap_test_t*) - Test framework to cleanup ### Test Execution #### `dap_test_run_all()` Executes all registered test suites. ```c int dap_test_run_all(dap_test_t *a_test); ``` **Parameters:** - `a_test` (dap_test_t*) - Test framework to execute **Returns:** - `0` - All tests completed (check results for pass/fail) - `-1` - Invalid test parameter - `-2` - Test execution failed #### `dap_test_run_suite()` Executes specific test suite. ```c int dap_test_run_suite(dap_test_t *a_test, const char *a_suite_name); ``` **Parameters:** - `a_test` (dap_test_t*) - Test framework - `a_suite_name` (const char*) - Name of suite to execute **Returns:** - `0` - Suite execution completed - `-1` - Invalid parameters - `-2` - Suite not found - `-3` - Suite execution failed #### `dap_test_run_case()` Executes specific test case. ```c int dap_test_run_case(dap_test_t *a_test, const char *a_suite_name, const char *a_case_name); ``` **Parameters:** - `a_test` (dap_test_t*) - Test framework - `a_suite_name` (const char*) - Suite containing the test case - `a_case_name` (const char*) - Test case to execute **Returns:** - `0` - Test case execution completed - `-1` - Invalid parameters - `-2` - Suite or case not found - `-3` - Test case execution failed #### `dap_test_get_results()` Retrieves test execution results. ```c dap_test_result_t* dap_test_get_results(dap_test_t *a_test); ``` **Parameters:** - `a_test` (dap_test_t*) - Test framework **Returns:** - `dap_test_result_t*` - Test execution results - `NULL` - No results available or invalid parameter ### Assertions #### `dap_test_assert_true()` Asserts that condition is true. ```c int dap_test_assert_true(bool a_condition, const char *a_message); ``` **Parameters:** - `a_condition` (bool) - Condition to test - `a_message` (const char*) - Assertion failure message **Returns:** - `0` - Assertion passed - `-1` - Assertion failed #### `dap_test_assert_equal()` Asserts that two values are equal. ```c int dap_test_assert_equal(const void *a_expected, const void *a_actual, size_t a_size, const char *a_message); ``` **Parameters:** - `a_expected` (const void*) - Expected value - `a_actual` (const void*) - Actual value - `a_size` (size_t) - Size of values to compare - `a_message` (const char*) - Assertion failure message **Returns:** - `0` - Values are equal - `-1` - Values are not equal #### `dap_test_assert_not_null()` Asserts that pointer is not NULL. ```c int dap_test_assert_not_null(const void *a_ptr, const char *a_message); ``` **Parameters:** - `a_ptr` (const void*) - Pointer to check - `a_message` (const char*) - Assertion failure message **Returns:** - `0` - Pointer is not NULL - `-1` - Pointer is NULL #### `dap_test_assert_string_equal()` Asserts that two strings are equal. ```c int dap_test_assert_string_equal(const char *a_expected, const char *a_actual, const char *a_message); ``` **Parameters:** - `a_expected` (const char*) - Expected string - `a_actual` (const char*) - Actual string - `a_message` (const char*) - Assertion failure message **Returns:** - `0` - Strings are equal - `-1` - Strings are not equal #### `dap_test_assert_memory_equal()` Asserts that memory regions are equal. ```c int dap_test_assert_memory_equal(const void *a_expected, const void *a_actual, size_t a_size, const char *a_message); ``` **Parameters:** - `a_expected` (const void*) - Expected memory content - `a_actual` (const void*) - Actual memory content - `a_size` (size_t) - Size of memory to compare - `a_message` (const char*) - Assertion failure message **Returns:** - `0` - Memory regions are equal - `-1` - Memory regions differ ### Benchmarking #### `dap_test_benchmark_create()` Creates new performance benchmark. ```c dap_test_benchmark_t* dap_test_benchmark_create(const char *a_name, dap_test_benchmark_func_t a_func, uint32_t a_iterations); ``` **Parameters:** - `a_name` (const char*) - Benchmark name - `a_func` (dap_test_benchmark_func_t) - Function to benchmark - `a_iterations` (uint32_t) - Number of iterations to run **Returns:** - `dap_test_benchmark_t*` - New benchmark instance - `NULL` - Creation failed or invalid parameters #### `dap_test_benchmark_run()` Executes performance benchmark. ```c int dap_test_benchmark_run(dap_test_benchmark_t *a_benchmark); ``` **Parameters:** - `a_benchmark` (dap_test_benchmark_t*) - Benchmark to execute **Returns:** - `0` - Benchmark completed successfully - `-1` - Invalid benchmark parameter - `-2` - Benchmark execution failed #### `dap_test_benchmark_get_stats()` Retrieves benchmark performance statistics. ```c int dap_test_benchmark_get_stats(dap_test_benchmark_t *a_benchmark, dap_test_benchmark_stats_t *a_stats); ``` **Parameters:** - `a_benchmark` (dap_test_benchmark_t*) - Benchmark instance - `a_stats` (dap_test_benchmark_stats_t*) - Output statistics structure **Returns:** - `0` - Statistics retrieved successfully - `-1` - Invalid parameters - `-2` - Benchmark not completed #### `dap_test_mock_create()` Creates mock object for testing. ```c void* dap_test_mock_create(const char *a_name, size_t a_size); ``` **Parameters:** - `a_name` (const char*) - Mock object name - `a_size` (size_t) - Size of mock object **Returns:** - `void*` - New mock object - `NULL` - Creation failed #### `dap_test_mock_set_return()` Sets return value for mock function. ```c int dap_test_mock_set_return(const char *a_mock_name, const char *a_function_name, void *a_return_value); ``` **Parameters:** - `a_mock_name` (const char*) - Mock object name - `a_function_name` (const char*) - Function to mock - `a_return_value` (void*) - Return value to set **Returns:** - `0` - Return value set successfully - `-1` - Invalid parameters - `-2` - Mock not found ## Error Codes ### DAP Test Error Codes ```c typedef enum dap_test_error { DAP_TEST_ERROR_SUCCESS = 0, // Operation successful DAP_TEST_ERROR_INVALID_PARAM, // Invalid parameter DAP_TEST_ERROR_NO_MEMORY, // Memory allocation failed DAP_TEST_ERROR_TEST_NOT_FOUND, // Test case not found DAP_TEST_ERROR_SUITE_NOT_FOUND, // Test suite not found DAP_TEST_ERROR_ASSERTION_FAILED, // Test assertion failed DAP_TEST_ERROR_TIMEOUT, // Test execution timeout DAP_TEST_ERROR_SETUP_FAILED, // Test setup failed DAP_TEST_ERROR_TEARDOWN_FAILED, // Test teardown failed DAP_TEST_ERROR_MOCK_NOT_FOUND, // Mock object not found DAP_TEST_ERROR_BENCHMARK_FAILED, // Benchmark execution failed DAP_TEST_ERROR_ALREADY_RUNNING, // Test already running DAP_TEST_ERROR_NOT_INITIALIZED, // Test framework not initialized DAP_TEST_ERROR_DEPENDENCY_MISSING // Test dependency missing } dap_test_error_t; ``` ## Typical Examples ### Basic Unit Testing Example ```c #include <dap_test.h> // Example test functions int test_basic_math(void *a_test_data) { log_it_info("Running basic math test"); // Test addition int result = 2 + 2; DAP_TEST_ASSERT_EQUAL(&result, &(int){4}, sizeof(int), "Addition test failed"); // Test subtraction result = 10 - 3; DAP_TEST_ASSERT_EQUAL(&result, &(int){7}, sizeof(int), "Subtraction test failed"); // Test multiplication result = 6 * 7; DAP_TEST_ASSERT_EQUAL(&result, &(int){42}, sizeof(int), "Multiplication test failed"); log_it_info("✓ Basic math test completed successfully"); return 0; } int test_string_operations(void *a_test_data) { log_it_info("Running string operations test"); // Test string comparison const char *str1 = "hello"; const char *str2 = "hello"; DAP_TEST_ASSERT_STRING_EQUAL(str1, str2, "String comparison failed"); // Test string length size_t len = strlen("test"); DAP_TEST_ASSERT_EQUAL(&len, &(size_t){4}, sizeof(size_t), "String length test failed"); // Test null pointer check char *buffer = malloc(100); DAP_TEST_ASSERT_NOT_NULL(buffer, "Memory allocation failed"); if (buffer) { strcpy(buffer, "test string"); DAP_TEST_ASSERT_STRING_EQUAL(buffer, "test string", "String copy failed"); free(buffer); } log_it_info("✓ String operations test completed successfully"); return 0; } int test_memory_operations(void *a_test_data) { log_it_info("Running memory operations test"); // Test memory allocation void *ptr = malloc(256); DAP_TEST_ASSERT_NOT_NULL(ptr, "Memory allocation failed"); if (ptr) { // Test memory initialization memset(ptr, 0xAA, 256); // Check first few bytes uint8_t expected_pattern[4] = {0xAA, 0xAA, 0xAA, 0xAA}; DAP_TEST_ASSERT_MEMORY_EQUAL(ptr, expected_pattern, 4, "Memory pattern failed"); free(ptr); } // Test memory comparison uint8_t array1[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; uint8_t array2[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; DAP_TEST_ASSERT_MEMORY_EQUAL(array1, array2, 10, "Array comparison failed"); log_it_info("✓ Memory operations test completed successfully"); return 0; } // Test setup and teardown functions int setup_basic_tests(void *a_test_data) { log_it_info("Setting up basic tests..."); // Initialize test data if needed return 0; } int teardown_basic_tests(void *a_test_data) { log_it_info("Tearing down basic tests..."); // Cleanup test data if needed return 0; } void unit_testing_example() { log_it_info("=== DAP Test Unit Testing Example ==="); // Create test configuration dap_test_config_t config = { .verbose_output = true, .stop_on_failure = false, .default_timeout_ms = 5000, .enable_logging = true, .log_level = DAP_LOG_INFO, .enable_benchmarking = false }; // Create test framework dap_test_t *test_framework = dap_test_new("BasicTestFramework", &config); if (!test_framework) { log_it_error("✗ Failed to create test framework"); return; } log_it_info("✓ Test framework created"); // Initialize framework int result = dap_test_init(test_framework); if (result != 0) { log_it_error("✗ Test framework initialization failed: %d", result); goto cleanup; } log_it_info("✓ Test framework initialized"); // Create test suite dap_test_suite_t basic_suite = { .pub.name = "BasicOperations", .pub.description = "Basic operation unit tests", .pub.is_enabled = true, .pub.type = DAP_TEST_SUITE_TYPE_UNIT, .priv.suite_setup = setup_basic_tests, .priv.suite_teardown = teardown_basic_tests }; // Create test cases dap_test_case_t test_cases[] = { { .pub.name = "test_basic_math", .pub.description = "Test basic mathematical operations", .pub.test_func = test_basic_math, .pub.priority = DAP_TEST_PRIORITY_NORMAL, .pub.timeout_ms = 1000, .pub.is_enabled = true }, { .pub.name = "test_string_operations", .pub.description = "Test string manipulation functions", .pub.test_func = test_string_operations, .pub.priority = DAP_TEST_PRIORITY_NORMAL, .pub.timeout_ms = 2000, .pub.is_enabled = true }, { .pub.name = "test_memory_operations", .pub.description = "Test memory allocation and manipulation", .pub.test_func = test_memory_operations, .pub.priority = DAP_TEST_PRIORITY_HIGH, .pub.timeout_ms = 3000, .pub.is_enabled = true } }; // Add test cases to suite basic_suite.pub.test_cases = test_cases; basic_suite.pub.test_cases_count = 3; // Register test suite result = dap_test_suite_register(test_framework, &basic_suite); if (result != 0) { log_it_error("✗ Failed to register test suite: %d", result); goto cleanup; } log_it_info("✓ Test suite registered with %d test cases", basic_suite.pub.test_cases_count); // Run all tests log_it_info("Executing all tests..."); result = dap_test_run_all(test_framework); if (result != 0) { log_it_error("✗ Test execution failed: %d", result); } else { log_it_info("✓ Test execution completed"); } // Get and display results dap_test_result_t *results = dap_test_get_results(test_framework); if (results) { log_it_info("Test Results Summary:"); log_it_info(" Total tests run: %lu", test_framework->priv.tests_run); log_it_info(" Tests passed: %lu", test_framework->priv.tests_passed); log_it_info(" Tests failed: %lu", test_framework->priv.tests_failed); log_it_info(" Execution time: %lu ms", results->pub.execution_time_ms); log_it_info(" Total assertions: %d", results->pub.assertions_total); log_it_info(" Passed assertions: %d", results->pub.assertions_passed); log_it_info(" Failed assertions: %d", results->priv.assertions_failed); // Calculate success rate if (test_framework->priv.tests_run > 0) { double success_rate = (double)test_framework->priv.tests_passed / test_framework->priv.tests_run * 100.0; log_it_info(" Success rate: %.1f%%", success_rate); } if (test_framework->priv.tests_failed == 0) { log_it_info("✓ All tests passed successfully!"); } else { log_it_info("✗ Some tests failed - check individual results"); } } else { log_it_error("✗ Failed to get test results"); } log_it_info("✓ Unit testing example completed"); cleanup: if (test_framework) { dap_test_cleanup(test_framework); } log_it_info("Unit testing example completed"); } ``` ### Performance Benchmarking Example ```c #include <dap_test.h> // Benchmark functions int benchmark_string_copy(void *a_data) { char src[1000]; char dst[1000]; // Initialize source string for (int i = 0; i < 999; i++) { src[i] = 'A' + (i % 26); } src[999] = '\0'; // Perform string copy strcpy(dst, src); return 0; } int benchmark_memory_allocation(void *a_data) { void *ptr = malloc(1024); if (ptr) { memset(ptr, 0, 1024); free(ptr); } return 0; } int benchmark_hash_calculation(void *a_data) { const char *data = "This is test data for hash calculation benchmark"; uint32_t hash = 0; // Simple hash calculation for (int i = 0; data[i]; i++) { hash = hash * 31 + data[i]; } return hash; // Return to prevent optimization } int benchmark_array_sorting(void *a_data) { int array[100]; // Initialize array with random values for (int i = 0; i < 100; i++) { array[i] = rand() % 1000; } // Simple bubble sort for (int i = 0; i < 99; i++) { for (int j = 0; j < 99 - i; j++) { if (array[j] > array[j + 1]) { int temp = array[j]; array[j] = array[j + 1]; array[j + 1] = temp; } } } return 0; } void performance_benchmarking_example() { log_it_info("=== DAP Test Performance Benchmarking Example ==="); // Create test configuration for benchmarking dap_test_config_t config = { .verbose_output = true, .enable_benchmarking = true, .benchmark_iterations = 10000, .enable_logging = true, .log_level = DAP_LOG_INFO }; // Create test framework dap_test_t *test_framework = dap_test_new("BenchmarkFramework", &config); if (!test_framework) { log_it_error("✗ Failed to create benchmark framework"); return; } // Initialize framework int result = dap_test_init(test_framework); if (result != 0) { log_it_error("✗ Benchmark framework initialization failed: %d", result); goto cleanup; } log_it_info("✓ Benchmark framework initialized"); // Define benchmarks to run struct { const char *name; dap_test_benchmark_func_t func; uint32_t iterations; } benchmarks[] = { {"String Copy", benchmark_string_copy, 100000}, {"Memory Allocation", benchmark_memory_allocation, 50000}, {"Hash Calculation", benchmark_hash_calculation, 200000}, {"Array Sorting", benchmark_array_sorting, 1000} }; const int num_benchmarks = sizeof(benchmarks) / sizeof(benchmarks[0]); // Run each benchmark for (int i = 0; i < num_benchmarks; i++) { log_it_info("Running benchmark: %s", benchmarks[i].name); // Create benchmark dap_test_benchmark_t *benchmark = dap_test_benchmark_create( benchmarks[i].name, benchmarks[i].func, benchmarks[i].iterations ); if (!benchmark) { log_it_error("✗ Failed to create benchmark: %s", benchmarks[i].name); continue; } // Run benchmark result = dap_test_benchmark_run(benchmark); if (result != 0) { log_it_error("✗ Benchmark execution failed: %s (%d)", benchmarks[i].name, result); continue; } // Get benchmark statistics dap_test_benchmark_stats_t stats; result = dap_test_benchmark_get_stats(benchmark, &stats); if (result == 0) { log_it_info("✓ Benchmark completed: %s", benchmarks[i].name); log_it_info(" Iterations: %d", benchmark->pub.iterations); log_it_info(" Min time: %lu ns", benchmark->pub.min_time_ns); log_it_info(" Max time: %lu ns", benchmark->pub.max_time_ns); log_it_info(" Avg time: %lu ns", benchmark->pub.avg_time_ns); log_it_info(" Total time: %lu ns", benchmark->priv.total_time_ns); log_it_info(" Std deviation: %.2f ns", benchmark->priv.std_deviation); // Calculate operations per second if (benchmark->pub.avg_time_ns > 0) { double ops_per_sec = 1000000000.0 / benchmark->pub.avg_time_ns; log_it_info(" Operations/sec: %.0f", ops_per_sec); } // Memory usage if available if (benchmark->priv.memory_used > 0) { log_it_info(" Memory used: %lu bytes", benchmark->priv.memory_used); } } else { log_it_error("✗ Failed to get benchmark statistics: %s", benchmarks[i].name); } // Cleanup benchmark dap_test_benchmark_delete(benchmark); log_it_info(""); } // Performance comparison log_it_info("Performance Summary:"); log_it_info(" String operations are generally fast for small strings"); log_it_info(" Memory allocation has variable performance due to system overhead"); log_it_info(" Hash calculations scale linearly with input size"); log_it_info(" Sorting algorithms have O(n²) complexity for bubble sort"); log_it_info("✓ Performance benchmarking example completed"); cleanup: if (test_framework) { dap_test_cleanup(test_framework); } log_it_info("Performance benchmarking example completed"); } ``` --- *See also: [[Module DAP Core|Core Foundation]], [[Module DAP IO|I/O Testing]], [[ETC/Architecture Overview|System Architecture]]*