|
infix
A JIT-Powered FFI Library for C
|
A micro-benchmark to measure the performance of trampoline generation. More...
Macros | |
| #define | DBLTAP_IMPLEMENTATION |
| #define | BENCHMARK_ITERATIONS 10000 |
Functions | |
| void | benchmark_handler (Point p) |
| A dummy handler function to provide a valid function pointer for creation. | |
| diag ("Trampoline Generation Benchmark") | |
| diag ("Iterations: %d", BENCHMARK_ITERATIONS) | |
| diag ("Target: Full create/destroy cycle for a reverse callback with signature 'void(Point)'") | |
| for (int i=0;i< BENCHMARK_ITERATIONS;++i) | |
| diag ("Total time: %.4f s", total_time) | |
| diag ("Average generation time: %.2f us/op", time_per_generation_us) | |
| pass ("Benchmark completed successfully.") | |
Variables | |
| TEST | |
| clock_t | start = clock() |
| clock_t | end = clock() |
| double | total_time = ((double)(end - start)) / CLOCKS_PER_SEC |
| double | time_per_generation_us = (total_time / BENCHMARK_ITERATIONS) * 1e6 |
A micro-benchmark to measure the performance of trampoline generation.
This is not a correctness test, but a performance benchmark. Its purpose is to measure the time it takes to perform a complete create/destroy cycle for a reverse trampoline. This is a key metric for applications that need to create callbacks dynamically and frequently.
The benchmark runs a tight loop that, in each iteration:
infix_type for a struct.infix_reverse_create_callback_manual to generate a JIT-compiled callback.The output is the average time for one complete cycle, reported in microseconds per operation (us/op). This metric is useful for tracking the performance of the entire JIT pipeline, including type creation, ABI classification, code emission, and memory management.
| #define BENCHMARK_ITERATIONS 10000 |
| #define DBLTAP_IMPLEMENTATION |
| void benchmark_handler | ( | Point | p | ) |
A dummy handler function to provide a valid function pointer for creation.
| diag | ( | "Average generation time: %.2f us/op" | , |
| time_per_generation_us | |||
| ) |
| diag | ( | "Iterations: %d" | , |
| BENCHMARK_ITERATIONS | |||
| ) |
| diag | ( | "Total time: %.4f s" | , |
| total_time | |||
| ) |
| diag | ( | "Trampoline Generation Benchmark" | ) |
| for | ( | ) |
| pass | ( | "Benchmark completed successfully." | ) |
| clock_t end = clock() |
| clock_t start = clock() |
| double time_per_generation_us = (total_time / BENCHMARK_ITERATIONS) * 1e6 |