Skip to content

Commit 7b59c6d

Browse files
Merge pull request #5 from ZenosInteractive/style/clang-format-sweep
style: apply clang-format across sdk, tests, samples, benchamarks and…
2 parents 078fcd6 + 8713698 commit 7b59c6d

198 files changed

Lines changed: 13451 additions & 13590 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.git-blame-ignore-revs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Revisions listed here are ignored by `git blame` so that purely
2+
# mechanical commits (reformatting, mass renames) don't overwrite
3+
# the blame history of every line they touch.
4+
#
5+
# GitHub honours this file automatically on the web UI. Locally, run:
6+
#
7+
# git config blame.ignoreRevsFile .git-blame-ignore-revs
8+
#
9+
# to make the local `git blame` respect it as well.
10+
#
11+
# Only add a SHA here when the commit is guaranteed to change no
12+
# semantics -- formatters, whitespace-only edits, renames.
13+
14+
# Repo-wide clang-format-15 sweep (2026-04-23)
15+
101feb407ac0fdfa1b96de37f625b40b716573b0

benchmarks/bench_accessor.cpp

Lines changed: 73 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -39,50 +39,50 @@
3939

4040
namespace {
4141

42-
// The arena replay lives under samples/content/reader/arena/. Benchmarks
43-
// run from various working dirs, so we resolve the path relative to the
44-
// fixtures dir that CMake exposes via VTX_BENCH_FIXTURES_DIR.
45-
std::string ArenaReplayPath() {
46-
return (std::filesystem::path(VTX_BENCH_FIXTURES_DIR).parent_path().parent_path()
47-
/ "samples" / "content" / "reader" / "arena" / "arena_from_fbs_ds.vtx")
48-
.string();
49-
}
42+
// The arena replay lives under samples/content/reader/arena/. Benchmarks
43+
// run from various working dirs, so we resolve the path relative to the
44+
// fixtures dir that CMake exposes via VTX_BENCH_FIXTURES_DIR.
45+
std::string ArenaReplayPath() {
46+
return (std::filesystem::path(VTX_BENCH_FIXTURES_DIR).parent_path().parent_path() / "samples" / "content" /
47+
"reader" / "arena" / "arena_from_fbs_ds.vtx")
48+
.string();
49+
}
5050

51-
struct SilenceDebugLogsOnce {
52-
SilenceDebugLogsOnce() { VTX::Logger::Instance().SetDebugEnabled(false); }
53-
};
54-
const SilenceDebugLogsOnce silence_accessor_debug_logs_once{};
55-
56-
// Small bundle that holds the reader + accessor + resolved keys. Moving
57-
// this construction out of the measured loop is intentional -- a real
58-
// integration resolves keys once at setup, not per frame.
59-
struct AccessorFixture {
60-
VTX::ReaderContext reader_result;
61-
VTX::FrameAccessor accessor;
62-
VTX::PropertyKey<VTX::Vector> key_position;
63-
VTX::PropertyKey<float> key_health;
64-
VTX::PropertyKey<std::string> key_unique_id;
65-
66-
static AccessorFixture Load(benchmark::State& state) {
67-
AccessorFixture f;
68-
f.reader_result = VTX::OpenReplayFile(ArenaReplayPath());
69-
if (!f.reader_result) {
70-
state.SkipWithError("OpenReplayFile failed (run vtx_sample_generate + vtx_sample_advance_write first)");
71-
return f;
72-
}
73-
f.accessor = f.reader_result.reader->CreateAccessor();
74-
f.key_position = f.accessor.Get<VTX::Vector>("Player", "Position");
75-
f.key_health = f.accessor.Get<float>("Player", "Health");
76-
f.key_unique_id = f.accessor.Get<std::string>("Player", "UniqueID");
51+
struct SilenceDebugLogsOnce {
52+
SilenceDebugLogsOnce() { VTX::Logger::Instance().SetDebugEnabled(false); }
53+
};
54+
const SilenceDebugLogsOnce silence_accessor_debug_logs_once {};
55+
56+
// Small bundle that holds the reader + accessor + resolved keys. Moving
57+
// this construction out of the measured loop is intentional -- a real
58+
// integration resolves keys once at setup, not per frame.
59+
struct AccessorFixture {
60+
VTX::ReaderContext reader_result;
61+
VTX::FrameAccessor accessor;
62+
VTX::PropertyKey<VTX::Vector> key_position;
63+
VTX::PropertyKey<float> key_health;
64+
VTX::PropertyKey<std::string> key_unique_id;
65+
66+
static AccessorFixture Load(benchmark::State& state) {
67+
AccessorFixture f;
68+
f.reader_result = VTX::OpenReplayFile(ArenaReplayPath());
69+
if (!f.reader_result) {
70+
state.SkipWithError("OpenReplayFile failed (run vtx_sample_generate + vtx_sample_advance_write first)");
71+
return f;
72+
}
73+
f.accessor = f.reader_result.reader->CreateAccessor();
74+
f.key_position = f.accessor.Get<VTX::Vector>("Player", "Position");
75+
f.key_health = f.accessor.Get<float>("Player", "Health");
76+
f.key_unique_id = f.accessor.Get<std::string>("Player", "UniqueID");
7777

78-
if (!f.key_position.IsValid() || !f.key_health.IsValid() || !f.key_unique_id.IsValid()) {
79-
state.SkipWithError("one or more Player keys did not resolve");
78+
if (!f.key_position.IsValid() || !f.key_health.IsValid() || !f.key_unique_id.IsValid()) {
79+
state.SkipWithError("one or more Player keys did not resolve");
80+
}
81+
return f;
8082
}
81-
return f;
82-
}
83-
};
83+
};
8484

85-
} // namespace
85+
} // namespace
8686

8787
// Open the replay, create the accessor, resolve three keys, then linearly
8888
// enumerate every frame, iterate every entity in the "entity" bucket, and
@@ -92,24 +92,27 @@ static void BM_AccessorSequentialScan(benchmark::State& state) {
9292
int32_t total_frames = 0;
9393
for (auto _ : state) {
9494
auto fixture = AccessorFixture::Load(state);
95-
if (!fixture.reader_result) break;
95+
if (!fixture.reader_result)
96+
break;
9697
auto& reader = fixture.reader_result.reader;
9798

9899
total_frames = reader->GetTotalFrames();
99100
double pos_accum = 0.0;
100-
float hp_accum = 0.0f;
101-
size_t id_count = 0;
101+
float hp_accum = 0.0f;
102+
size_t id_count = 0;
102103

103104
for (int32_t i = 0; i < total_frames; ++i) {
104105
const auto* frame = reader->GetFrameSync(i);
105-
if (!frame) continue;
106+
if (!frame)
107+
continue;
106108
for (const auto& bucket : frame->GetBuckets()) {
107109
for (const auto& entity : bucket.entities) {
108-
if (entity.entity_type_id != 0) continue; // 0 = Player
110+
if (entity.entity_type_id != 0)
111+
continue; // 0 = Player
109112
VTX::EntityView view(entity);
110113
pos_accum += view.Get(fixture.key_position).x;
111-
hp_accum += view.Get(fixture.key_health);
112-
id_count += view.Get(fixture.key_unique_id).size();
114+
hp_accum += view.Get(fixture.key_health);
115+
id_count += view.Get(fixture.key_unique_id).size();
113116
}
114117
}
115118
}
@@ -128,12 +131,15 @@ BENCHMARK(BM_AccessorSequentialScan)->Unit(benchmark::kMillisecond);
128131
// the replay in memory would observe when scrubbing over the properties.
129132
static void BM_AccessorHotLoopPreloaded(benchmark::State& state) {
130133
auto result = VTX::OpenReplayFile(ArenaReplayPath());
131-
if (!result) { state.SkipWithError("OpenReplayFile failed"); return; }
134+
if (!result) {
135+
state.SkipWithError("OpenReplayFile failed");
136+
return;
137+
}
132138
auto& reader = result.reader;
133139

134-
auto accessor = reader->CreateAccessor();
140+
auto accessor = reader->CreateAccessor();
135141
auto key_position = accessor.Get<VTX::Vector>("Player", "Position");
136-
auto key_health = accessor.Get<float>("Player", "Health");
142+
auto key_health = accessor.Get<float>("Player", "Health");
137143
if (!key_position.IsValid() || !key_health.IsValid()) {
138144
state.SkipWithError("keys did not resolve");
139145
return;
@@ -161,7 +167,8 @@ static void BM_AccessorHotLoopPreloaded(benchmark::State& state) {
161167
for (const auto& frame : ram_cache) {
162168
for (const auto& bucket : frame.GetBuckets()) {
163169
for (const auto& entity : bucket.entities) {
164-
if (entity.entity_type_id == 0) ++entities_per_sweep;
170+
if (entity.entity_type_id == 0)
171+
++entities_per_sweep;
165172
}
166173
}
167174
}
@@ -171,7 +178,8 @@ static void BM_AccessorHotLoopPreloaded(benchmark::State& state) {
171178
for (const auto& frame : ram_cache) {
172179
for (const auto& bucket : frame.GetBuckets()) {
173180
for (const auto& entity : bucket.entities) {
174-
if (entity.entity_type_id != 0) continue;
181+
if (entity.entity_type_id != 0)
182+
continue;
175183
VTX::EntityView view(entity);
176184
sink += view.Get(key_position).x + view.Get(key_health);
177185
}
@@ -189,10 +197,13 @@ BENCHMARK(BM_AccessorHotLoopPreloaded)->Unit(benchmark::kMillisecond);
189197
// behaviour under non-sequential access.
190198
static void BM_AccessorRandomWithinBucket(benchmark::State& state) {
191199
auto result = VTX::OpenReplayFile(ArenaReplayPath());
192-
if (!result) { state.SkipWithError("OpenReplayFile failed"); return; }
200+
if (!result) {
201+
state.SkipWithError("OpenReplayFile failed");
202+
return;
203+
}
193204
auto& reader = result.reader;
194205

195-
auto accessor = reader->CreateAccessor();
206+
auto accessor = reader->CreateAccessor();
196207
auto key_position = accessor.Get<VTX::Vector>("Player", "Position");
197208
if (!key_position.IsValid()) {
198209
state.SkipWithError("Player::Position did not resolve");
@@ -227,16 +238,20 @@ static void BM_AccessorRandomWithinBucket(benchmark::State& state) {
227238
std::vector<size_t> idxs;
228239
idxs.reserve(bucket.entities.size());
229240
for (size_t i = 0; i < bucket.entities.size(); ++i) {
230-
if (bucket.entities[i].entity_type_id == 0) idxs.push_back(i);
231-
if (bucket.entities[i].entity_type_id == 0) idxs.push_back(i);
241+
if (bucket.entities[i].entity_type_id == 0)
242+
idxs.push_back(i);
243+
if (bucket.entities[i].entity_type_id == 0)
244+
idxs.push_back(i);
232245
}
233-
if (idxs.size() < 2) continue;
246+
if (idxs.size() < 2)
247+
continue;
234248
std::shuffle(idxs.begin(), idxs.end(), rng);
235249
prepared.push_back({&bucket.entities, std::move(idxs)});
236250
}
237251
}
238252
int64_t ops_per_sweep = 0;
239-
for (const auto& pb : prepared) ops_per_sweep += static_cast<int64_t>(pb.shuffled.size());
253+
for (const auto& pb : prepared)
254+
ops_per_sweep += static_cast<int64_t>(pb.shuffled.size());
240255

241256
double sink = 0.0;
242257
for (auto _ : state) {

benchmarks/bench_accessor_key_resolution.cpp

Lines changed: 30 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -20,39 +20,45 @@
2020

2121
namespace {
2222

23-
std::string ArenaReplayPath() {
24-
return (std::filesystem::path(VTX_BENCH_FIXTURES_DIR).parent_path().parent_path()
25-
/ "samples" / "content" / "reader" / "arena" / "arena_from_fbs_ds.vtx")
26-
.string();
27-
}
23+
std::string ArenaReplayPath() {
24+
return (std::filesystem::path(VTX_BENCH_FIXTURES_DIR).parent_path().parent_path() / "samples" / "content" /
25+
"reader" / "arena" / "arena_from_fbs_ds.vtx")
26+
.string();
27+
}
2828

29-
struct SilenceDebugLogsOnce {
30-
SilenceDebugLogsOnce() { VTX::Logger::Instance().SetDebugEnabled(false); }
31-
};
32-
const SilenceDebugLogsOnce silence_keyres_debug_logs_once{};
29+
struct SilenceDebugLogsOnce {
30+
SilenceDebugLogsOnce() { VTX::Logger::Instance().SetDebugEnabled(false); }
31+
};
32+
const SilenceDebugLogsOnce silence_keyres_debug_logs_once {};
3333

34-
// A representative spread of property lookups a real integration performs.
35-
struct PropSpec { const char* struct_name; const char* prop_name; };
36-
constexpr std::array<PropSpec, 9> kProps = {{
37-
{"Player", "Position"},
38-
{"Player", "Health"},
39-
{"Player", "UniqueID"},
40-
{"Player", "Velocity"},
41-
{"Player", "Score"},
42-
{"Projectile", "Position"},
43-
{"Projectile", "Damage"},
44-
{"MatchState", "ScoreTeam1"},
45-
{"MatchState", "ScoreTeam2"},
46-
}};
34+
// A representative spread of property lookups a real integration performs.
35+
struct PropSpec {
36+
const char* struct_name;
37+
const char* prop_name;
38+
};
39+
constexpr std::array<PropSpec, 9> kProps = {{
40+
{"Player", "Position"},
41+
{"Player", "Health"},
42+
{"Player", "UniqueID"},
43+
{"Player", "Velocity"},
44+
{"Player", "Score"},
45+
{"Projectile", "Position"},
46+
{"Projectile", "Damage"},
47+
{"MatchState", "ScoreTeam1"},
48+
{"MatchState", "ScoreTeam2"},
49+
}};
4750

48-
} // namespace
51+
} // namespace
4952

5053
// Resolve a full set of PropertyKey<T> via the public accessor API. If
5154
// the underlying cache is O(1) then time-per-resolution should stay
5255
// constant regardless of how many properties the schema defines.
5356
static void BM_AccessorKeyResolution(benchmark::State& state) {
5457
auto result = VTX::OpenReplayFile(ArenaReplayPath());
55-
if (!result) { state.SkipWithError("OpenReplayFile failed"); return; }
58+
if (!result) {
59+
state.SkipWithError("OpenReplayFile failed");
60+
return;
61+
}
5662

5763
const auto accessor = result.reader->CreateAccessor();
5864

0 commit comments

Comments
 (0)