Skip to content

Commit 19905c0

Browse files
committed
C betnchmark : reset world between run
1 parent 3938e2d commit 19905c0

2 files changed

Lines changed: 51 additions & 43 deletions

File tree

benchmark/results/benchmark-results.txt

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -10,68 +10,68 @@ GCC : gcc (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0
1010
============================================================
1111

1212
BENCHMARK RESULTS — flecs-java vs flecs C vs Artemis-odb
13-
Date : 2026-02-27 14:36:30
13+
Date : 2026-02-27 15:02:57
1414

1515
[ Java / JMH ]
1616
------------------------------------------------------------
1717
Benchmark Mode Cnt Score Error Units
1818
c.g.e.f.b.artemisodb.EntityCreationBenchmark.create avgt 3 0,012 ± 0,001 us/op
19-
c.g.e.f.b.artemisodb.EntityCreationBenchmark.create:·gc.alloc.rate avgt 3 5770,913 ± 186,332 MB/sec
19+
c.g.e.f.b.artemisodb.EntityCreationBenchmark.create:·gc.alloc.rate avgt 3 5791,911 ± 57,546 MB/sec
2020
c.g.e.f.b.artemisodb.EntityCreationBenchmark.create:·gc.alloc.rate.norm avgt 3 75,435 ± 0,001 B/op
21-
c.g.e.f.b.artemisodb.EntityCreationBenchmark.create:·gc.count avgt 3 46,000 counts
22-
c.g.e.f.b.artemisodb.EntityCreationBenchmark.create:·gc.time avgt 3 25,000 ms
23-
c.g.e.f.b.artemisodb.EntityCreationBenchmark.createWith2Components avgt 3 0,070 ± 0,001 us/op
24-
c.g.e.f.b.artemisodb.EntityCreationBenchmark.createWith2Components:·gc.alloc.rate avgt 3 2168,045 ± 30,569 MB/sec
21+
c.g.e.f.b.artemisodb.EntityCreationBenchmark.create:·gc.count avgt 3 50,000 counts
22+
c.g.e.f.b.artemisodb.EntityCreationBenchmark.create:·gc.time avgt 3 35,000 ms
23+
c.g.e.f.b.artemisodb.EntityCreationBenchmark.createWith2Components avgt 3 0,071 ± 0,001 us/op
24+
c.g.e.f.b.artemisodb.EntityCreationBenchmark.createWith2Components:·gc.alloc.rate avgt 3 2162,063 ± 35,120 MB/sec
2525
c.g.e.f.b.artemisodb.EntityCreationBenchmark.createWith2Components:·gc.alloc.rate.norm avgt 3 160,409 ± 0,001 B/op
26-
c.g.e.f.b.artemisodb.EntityCreationBenchmark.createWith2Components:·gc.count avgt 3 21,000 counts
27-
c.g.e.f.b.artemisodb.EntityCreationBenchmark.createWith2Components:·gc.time avgt 3 35,000 ms
28-
c.g.e.f.b.artemisodb.EntityCreationBenchmark.createWith2ComponentsFromPrefab avgt 3 0,037 ± 0,002 us/op
29-
c.g.e.f.b.artemisodb.EntityCreationBenchmark.createWith2ComponentsFromPrefab:·gc.alloc.rate avgt 3 2970,476 ± 141,136 MB/sec
26+
c.g.e.f.b.artemisodb.EntityCreationBenchmark.createWith2Components:·gc.count avgt 3 20,000 counts
27+
c.g.e.f.b.artemisodb.EntityCreationBenchmark.createWith2Components:·gc.time avgt 3 54,000 ms
28+
c.g.e.f.b.artemisodb.EntityCreationBenchmark.createWith2ComponentsFromPrefab avgt 3 0,037 ± 0,005 us/op
29+
c.g.e.f.b.artemisodb.EntityCreationBenchmark.createWith2ComponentsFromPrefab:·gc.alloc.rate avgt 3 2954,763 ± 359,537 MB/sec
3030
c.g.e.f.b.artemisodb.EntityCreationBenchmark.createWith2ComponentsFromPrefab:·gc.alloc.rate.norm avgt 3 115,435 ± 0,001 B/op
31-
c.g.e.f.b.artemisodb.EntityCreationBenchmark.createWith2ComponentsFromPrefab:·gc.count avgt 3 28,000 counts
32-
c.g.e.f.b.artemisodb.EntityCreationBenchmark.createWith2ComponentsFromPrefab:·gc.time avgt 3 41,000 ms
31+
c.g.e.f.b.artemisodb.EntityCreationBenchmark.createWith2ComponentsFromPrefab:·gc.count avgt 3 29,000 counts
32+
c.g.e.f.b.artemisodb.EntityCreationBenchmark.createWith2ComponentsFromPrefab:·gc.time avgt 3 30,000 ms
3333
c.g.e.f.b.artemisodb.QueryBenchmark.query avgt 3 0,002 ± 0,001 us/op
3434
c.g.e.f.b.artemisodb.QueryBenchmark.query:·gc.alloc.rate avgt 3 ≈ 10⁻³ MB/sec
3535
c.g.e.f.b.artemisodb.QueryBenchmark.query:·gc.alloc.rate.norm avgt 3 ≈ 10⁻⁶ B/op
3636
c.g.e.f.b.artemisodb.QueryBenchmark.query:·gc.count avgt 3 ≈ 0 counts
3737
c.g.e.f.b.flecs.EntityCreationBenchmark.create avgt 3 0,014 ± 0,001 us/op
38-
c.g.e.f.b.flecs.EntityCreationBenchmark.create:·gc.alloc.rate avgt 3 0,496 ± 0,060 MB/sec
38+
c.g.e.f.b.flecs.EntityCreationBenchmark.create:·gc.alloc.rate avgt 3 0,497 ± 0,009 MB/sec
3939
c.g.e.f.b.flecs.EntityCreationBenchmark.create:·gc.alloc.rate.norm avgt 3 0,027 ± 0,001 B/op
4040
c.g.e.f.b.flecs.EntityCreationBenchmark.create:·gc.count avgt 3 ≈ 0 counts
41-
c.g.e.f.b.flecs.EntityCreationBenchmark.createWith2Components avgt 3 0,158 ± 0,012 us/op
42-
c.g.e.f.b.flecs.EntityCreationBenchmark.createWith2Components:·gc.alloc.rate avgt 3 302,041 ± 25,250 MB/sec
41+
c.g.e.f.b.flecs.EntityCreationBenchmark.createWith2Components avgt 3 0,158 ± 0,039 us/op
42+
c.g.e.f.b.flecs.EntityCreationBenchmark.createWith2Components:·gc.alloc.rate avgt 3 303,679 ± 67,835 MB/sec
4343
c.g.e.f.b.flecs.EntityCreationBenchmark.createWith2Components:·gc.alloc.rate.norm avgt 3 64,032 ± 0,001 B/op
4444
c.g.e.f.b.flecs.EntityCreationBenchmark.createWith2Components:·gc.count avgt 3 7,000 counts
45-
c.g.e.f.b.flecs.EntityCreationBenchmark.createWith2Components:·gc.time avgt 3 3,000 ms
46-
c.g.e.f.b.flecs.EntityCreationBenchmark.createWith2ComponentsFromPrefab avgt 3 0,195 ± 0,008 us/op
47-
c.g.e.f.b.flecs.EntityCreationBenchmark.createWith2ComponentsFromPrefab:·gc.alloc.rate avgt 3 0,132 ± 0,005 MB/sec
45+
c.g.e.f.b.flecs.EntityCreationBenchmark.createWith2Components:·gc.time avgt 3 2,000 ms
46+
c.g.e.f.b.flecs.EntityCreationBenchmark.createWith2ComponentsFromPrefab avgt 3 0,198 ± 0,016 us/op
47+
c.g.e.f.b.flecs.EntityCreationBenchmark.createWith2ComponentsFromPrefab:·gc.alloc.rate avgt 3 0,131 ± 0,010 MB/sec
4848
c.g.e.f.b.flecs.EntityCreationBenchmark.createWith2ComponentsFromPrefab:·gc.alloc.rate.norm avgt 3 0,033 ± 0,001 B/op
4949
c.g.e.f.b.flecs.EntityCreationBenchmark.createWith2ComponentsFromPrefab:·gc.count avgt 3 ≈ 0 counts
50-
c.g.e.f.b.flecs.EntityCreationBenchmark.createWith2ComponentsNoAlloc avgt 3 0,150 ± 0,018 us/op
51-
c.g.e.f.b.flecs.EntityCreationBenchmark.createWith2ComponentsNoAlloc:·gc.alloc.rate avgt 3 0,213 ± 0,023 MB/sec
50+
c.g.e.f.b.flecs.EntityCreationBenchmark.createWith2ComponentsNoAlloc avgt 3 0,150 ± 0,016 us/op
51+
c.g.e.f.b.flecs.EntityCreationBenchmark.createWith2ComponentsNoAlloc:·gc.alloc.rate avgt 3 0,213 ± 0,022 MB/sec
5252
c.g.e.f.b.flecs.EntityCreationBenchmark.createWith2ComponentsNoAlloc:·gc.alloc.rate.norm avgt 3 0,043 ± 0,001 B/op
5353
c.g.e.f.b.flecs.EntityCreationBenchmark.createWith2ComponentsNoAlloc:·gc.count avgt 3 ≈ 0 counts
5454
c.g.e.f.b.flecs.QueryBenchmark.query avgt 3 0,002 ± 0,001 us/op
55-
c.g.e.f.b.flecs.QueryBenchmark.query:·gc.alloc.rate avgt 3 1,519 ± 4,749 MB/sec
56-
c.g.e.f.b.flecs.QueryBenchmark.query:·gc.alloc.rate.norm avgt 3 0,002 ± 0,008 B/op
55+
c.g.e.f.b.flecs.QueryBenchmark.query:·gc.alloc.rate avgt 3 1,633 ± 4,773 MB/sec
56+
c.g.e.f.b.flecs.QueryBenchmark.query:·gc.alloc.rate.norm avgt 3 0,003 ± 0,008 B/op
5757
c.g.e.f.b.flecs.QueryBenchmark.query:·gc.count avgt 3 ≈ 0 counts
5858

5959
[ C / Native ]
6060
------------------------------------------------------------
61-
Runs : 0 | Warmup: 1987804344 | Iterations: 0
61+
Runs : 0 | Warmup: -985056072 | Iterations: 0
6262
Benchmark: create
6363
Mode: AverageTime, Time: us
64-
Score: 0.033457 ± 0.025265 us/op (batch avg: 3345.658 us, stddev: 5428.366 us)
64+
Score: 0.016612 ± 0.000586 us/op (batch avg: 1661.164 us, stddev: 125.821 us)
6565
---------------------------------------------------
6666
Benchmark: createWith2Components
6767
Mode: AverageTime, Time: us
68-
Score: 0.129226 ± 0.040631 us/op (batch avg: 12922.574 us, stddev: 8729.949 us)
68+
Score: 0.115707 ± 0.001028 us/op (batch avg: 11570.671 us, stddev: 220.919 us)
6969
---------------------------------------------------
7070
Benchmark: createWith2ComponentsFromPrefab
7171
Mode: AverageTime, Time: us
72-
Score: 0.114965 ± 0.012829 us/op (batch avg: 11496.513 us, stddev: 2756.404 us)
72+
Score: 0.106134 ± 0.000644 us/op (batch avg: 10613.443 us, stddev: 138.276 us)
7373
---------------------------------------------------
7474
Benchmark: query
7575
Mode: AverageTime, Time: us
76-
Score: 0.000833 ± 0.000005 us/op (batch avg: 83.266 us, stddev: 1.124 us)
76+
Score: 0.000882 ± 0.000019 us/op (batch avg: 88.151 us, stddev: 4.190 us)
7777
---------------------------------------------------

benchmark/src/jmh/c/benchmark_utils.c

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -31,29 +31,37 @@ void benchmark_world_populate(ecs_world_t *world, int count) {
3131

3232
void benchmark_run(
3333
const char *name,
34-
void (*setup) (void *ctx),
35-
void (*teardown)(void *ctx),
36-
void (*fn) (void *ctx),
37-
void *ctx,
34+
void (*setup)(void *ctx),
35+
void (*teardown)(void *ctx),
36+
void (*fn)(void *ctx),
37+
void *ctx,
3838
BenchmarkResult *out
3939
) {
40-
if (setup) setup(ctx);
41-
4240
for (int i = 0; i < BENCH_WARMUP_RUNS; i++) {
41+
if (setup) {
42+
setup(ctx);
43+
}
4344
fn(ctx);
45+
if (teardown) {
46+
teardown(ctx);
47+
}
4448
}
4549

4650
double *samples = malloc(sizeof(double) * BENCH_RUNS);
4751

4852
for (int run = 0; run < BENCH_RUNS; run++) {
53+
if (setup) {
54+
setup(ctx);
55+
}
4956
double start = benchmark_time_us();
5057
fn(ctx);
51-
double end = benchmark_time_us();
58+
double end = benchmark_time_us();
59+
if (teardown) {
60+
teardown(ctx);
61+
}
5262
samples[run] = end - start;
5363
}
5464

55-
if (teardown) teardown(ctx);
56-
5765
double sum = 0.0;
5866
for (int i = 0; i < BENCH_RUNS; i++) sum += samples[i];
5967
double avg = sum / BENCH_RUNS;
@@ -70,13 +78,13 @@ void benchmark_run(
7078

7179
free(samples);
7280

73-
out->name = name;
74-
out->avg_us = avg;
75-
out->per_op_us = avg / BENCH_ITERATIONS;
76-
out->stddev_us = stddev;
77-
out->error_us = error;
78-
out->runs = BENCH_RUNS;
79-
out->iterations = BENCH_ITERATIONS;
81+
out->name = name;
82+
out->avg_us = avg;
83+
out->per_op_us = avg / BENCH_ITERATIONS;
84+
out->stddev_us = stddev;
85+
out->error_us = error;
86+
out->runs = BENCH_RUNS;
87+
out->iterations = BENCH_ITERATIONS;
8088
}
8189

8290

0 commit comments

Comments
 (0)