MCPcopy Create free account
hub / github.com/codr7/hacktical-c / dsl_benchmarks

Function dsl_benchmarks

dsl/benchmarks.c:4–35  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2#include "dsl.h"
3
4void dsl_benchmarks() {
5 hc_time_t t;
6 const int n = 100000;
7
8 char buf[32];
9 t = hc_now();
10
11 for (int i = 0; i < n; i++) {
12 sprintf(buf, "abc %s def", "ghi");
13 }
14
15 hc_time_print(&t, "sprintf: ");
16
17 struct hc_dsl dsl;
18 hc_dsl_init(&dsl, &hc_malloc_default);
19 hc_defer(hc_dsl_deinit(&dsl));
20 struct hc_memory_stream out;
21 hc_memory_stream_init(&out, &hc_malloc_default);
22 hc_defer(hc_stream_deinit(&out.stream));
23 dsl.out = &out.stream;
24 hc_dsl_set_string(&dsl, "foo", "ghi");
25 hc_dsl_eval(&dsl, "abc $(print foo) def");
26
27 t = hc_now();
28
29 for (int i = 0; i < n; i++) {
30 hc_vector_clear(&out.data);
31 hc_vm_eval(&dsl.vm, 0, -1);
32 }
33
34 hc_time_print(&t, "dsl: ");
35}

Callers 1

mainFunction · 0.85

Calls 10

hc_nowFunction · 0.85
hc_time_printFunction · 0.85
hc_dsl_initFunction · 0.85
hc_dsl_deinitFunction · 0.85
hc_memory_stream_initFunction · 0.85
hc_stream_deinitFunction · 0.85
hc_dsl_set_stringFunction · 0.85
hc_dsl_evalFunction · 0.85
hc_vector_clearFunction · 0.85
hc_vm_evalFunction · 0.85

Tested by

no test coverage detected