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

Measures the performance of infix_register_types with many definitions. More...

#include "common/compat_c23.h"
#include "common/double_tap.h"
#include <infix/infix.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
Include dependency graph for 904_registry_benchmark.c:

Macros

#define DBLTAP_IMPLEMENTATION
#define BENCHMARK_ITERATIONS   100
#define TYPES_PER_ITERATION   1000

Functions

 diag ("Type Registry Registration Benchmark")
 diag ("Iterations: %d", BENCHMARK_ITERATIONS)
 diag ("Types per iteration: %d", TYPES_PER_ITERATION)
 for (int i=0;i< TYPES_PER_ITERATION;++i)
 free (defs)
 diag ("Total time: %.4f s", total_time)
 diag ("Average registration time (%d types): %.2f ms", TYPES_PER_ITERATION, time_per_op_ms)
 pass ("Benchmark completed successfully.")

Variables

 TEST
size_t buf_size = TYPES_PER_ITERATION * 32
char * defs = malloc(buf_size)
char * p = defs
clock_t start = clock()
clock_t end = clock()
double total_time = ((double)(end - start)) / CLOCKS_PER_SEC
double time_per_op_ms = (total_time / BENCHMARK_ITERATIONS) * 1e3

Detailed Description

Measures the performance of infix_register_types with many definitions.

Macro Definition Documentation

◆ BENCHMARK_ITERATIONS

#define BENCHMARK_ITERATIONS   100

◆ DBLTAP_IMPLEMENTATION

#define DBLTAP_IMPLEMENTATION

◆ TYPES_PER_ITERATION

#define TYPES_PER_ITERATION   1000

Function Documentation

◆ diag() [1/5]

diag ( "Average registration time (%d types): %.2f ms" ,
TYPES_PER_ITERATION ,
time_per_op_ms  )

◆ diag() [2/5]

diag ( "Iterations: %d" ,
BENCHMARK_ITERATIONS  )

◆ diag() [3/5]

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

◆ diag() [4/5]

diag ( "Type Registry Registration Benchmark" )

◆ diag() [5/5]

diag ( "Types per iteration: %d" ,
TYPES_PER_ITERATION  )

◆ for()

for ( )

◆ free()

free ( defs )

◆ pass()

pass ( "Benchmark completed successfully." )

Variable Documentation

◆ buf_size

size_t buf_size = TYPES_PER_ITERATION * 32

◆ defs

char* defs = malloc(buf_size)

◆ end

clock_t end = clock()

◆ p

char* p = defs

◆ start

clock_t start = clock()

◆ TEST

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

◆ time_per_op_ms

double time_per_op_ms = (total_time / BENCHMARK_ITERATIONS) * 1e3

◆ total_time

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