infix
A JIT-Powered FFI Library for C
Loading...
Searching...
No Matches
903_generation_benchmark.c File Reference

A microbenchmark for FFI trampoline generation time. More...

#include "common/double_tap.h"
#include "types.h"
#include <infix/infix.h>
#include <time.h>
Include dependency graph for 903_generation_benchmark.c:

Macros

#define DBLTAP_IMPLEMENTATION
 
#define BENCHMARK_ITERATIONS   10000
 

Functions

void benchmark_handler (Point p)
 
 diag ("Trampoline Generation Benchmark")
 
 diag ("Iterations: %d", BENCHMARK_ITERATIONS)
 
 diag ("Target: infix_reverse_create_callback_manual for Point(Point) using arena API")
 
 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
 

Detailed Description

A microbenchmark for FFI trampoline generation time.

Copyright (c) 2025 Sanko Robinson

This source code is dual-licensed under the Artistic License 2.0 or the MIT License. You may choose to use this code under the terms of either license.

SPDX-License-Identifier: (Artistic-2.0 OR MIT)

The documentation blocks within this file are licensed under the Creative Commons Attribution 4.0 International License (CC BY 4.0).

SPDX-License-Identifier: CC-BY-4.0

This test measures the performance of the trampoline creation process, which was the target of the arena allocator optimization. It should not be run as part of the regular test suite.

It repeatedly generates and destroys a reverse trampoline for a complex function signature using the manual, arena-based API. This measures the full setup cost and quantifies the performance of the type system and JIT generator.

Macro Definition Documentation

◆ BENCHMARK_ITERATIONS

#define BENCHMARK_ITERATIONS   10000

◆ DBLTAP_IMPLEMENTATION

#define DBLTAP_IMPLEMENTATION

Function Documentation

◆ benchmark_handler()

void benchmark_handler ( Point  p)

◆ diag() [1/5]

diag ( "Average generation time: %.2f us/op"  ,
time_per_generation_us   
)

◆ diag() [2/5]

diag ( "Iterations: %d"  ,
BENCHMARK_ITERATIONS   
)

◆ diag() [3/5]

diag ( "Target: infix_reverse_create_callback_manual for Point(Point) using arena API"  )

◆ diag() [4/5]

diag ( "Total time: %.4f s"  ,
total_time   
)

◆ diag() [5/5]

diag ( "Trampoline Generation Benchmark"  )

◆ for()

for ( )

◆ pass()

pass ( "Benchmark completed successfully."  )

Variable Documentation

◆ end

clock_t end = clock()

◆ start

clock_t start = clock()

◆ TEST

TEST
Initial value:
{
plan(1)
#define plan(count)
Definition double_tap.h:132

◆ time_per_generation_us

double time_per_generation_us = (total_time / BENCHMARK_ITERATIONS) * 1e6

◆ total_time

double total_time = ((double)(end - start)) / CLOCKS_PER_SEC