MCPcopy Create free account
hub / github.com/PerroEngine/Perro / generated_code

Function generated_code

perro_source/io_stack/perro_io/build.rs:13–53  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

11}
12
13fn generated_code() -> String {
14 let mut code = String::from("// generated by perro_io/build.rs\n\n");
15
16 for size in SIZES {
17 let mut rows = (0..size)
18 .map(|index| (bench_key(index as u64), index as u32))
19 .collect::<Vec<_>>();
20 rows.sort_unstable_by_key(|(key, _)| *key);
21
22 code.push_str(&format!(
23 "static AOS_TABLE_{size}: [(u64, u32); {size}] = [\n"
24 ));
25 for (key, value) in &rows {
26 code.push_str(&format!(" ({key:#018x}, {value}),\n"));
27 }
28 code.push_str("];\n\n");
29
30 code.push_str(&format!("static SOA_HASHES_{size}: [u64; {size}] = [\n"));
31 for (key, _) in &rows {
32 code.push_str(&format!(" {key:#018x},\n"));
33 }
34 code.push_str("];\n\n");
35
36 code.push_str(&format!("static SOA_VALUES_{size}: [u32; {size}] = [\n"));
37 for (_, value) in &rows {
38 code.push_str(&format!(" {value},\n"));
39 }
40 code.push_str("];\n\n");
41
42 let probes = [
43 bench_key(0),
44 bench_key((size / 2) as u64),
45 bench_key((size - 1) as u64),
46 bench_key((size as u64).wrapping_add(17)),
47 ];
48 code.push_str(&format!("static PROBES_{size}: [u64; 4] = [\n"));
49 for probe in probes {
50 code.push_str(&format!(" {probe:#018x},\n"));
51 }
52 code.push_str("];\n\n");
53
54 code.push_str(&format!(
55 "#[inline(never)]\nfn match_lookup_{size}(key: u64) -> Option<u32> {{\n match key {{\n"
56 ));

Callers 1

mainFunction · 0.85

Calls 1

bench_keyFunction · 0.85

Tested by

no test coverage detected