time: add power-of-2 kHz tick rates.

Fixes #1269
This commit is contained in:
Dario Nieuwenhuis 2023-03-09 23:32:00 +01:00
parent c9d89f391b
commit 79061021f9
3 changed files with 84 additions and 4 deletions

View File

@ -101,6 +101,25 @@ tick-hz-2_097_152 = []
tick-hz-4_194_304 = []
tick-hz-8_388_608 = []
tick-hz-16_777_216 = []
tick-hz-2_000 = []
tick-hz-4_000 = []
tick-hz-8_000 = []
tick-hz-16_000 = []
tick-hz-32_000 = []
tick-hz-64_000 = []
tick-hz-128_000 = []
tick-hz-256_000 = []
tick-hz-512_000 = []
tick-hz-1_024_000 = []
tick-hz-2_048_000 = []
tick-hz-4_096_000 = []
tick-hz-8_192_000 = []
tick-hz-16_384_000 = []
tick-hz-32_768_000 = []
tick-hz-65_536_000 = []
tick-hz-131_072_000 = []
tick-hz-262_144_000 = []
tick-hz-524_288_000 = []
tick-hz-2_000_000 = []
tick-hz-3_000_000 = []
tick-hz-4_000_000 = []

View File

@ -11,6 +11,8 @@ for i in range(10):
ticks.append(10**i)
for i in range(1, 25):
ticks.append(2**i)
for i in range(1, 20):
ticks.append(2**i * 1000)
for i in range(1, 10):
ticks.append(2**i * 1000000)
ticks.append(2**i * 9 // 8 * 1000000)
@ -30,21 +32,23 @@ with open('Cargo.toml', 'r') as f:
data = f.read()
before, data = data.split(SEPARATOR_START, maxsplit=1)
_, after = data.split(SEPARATOR_END, maxsplit=1)
data = before + SEPARATOR_START + HELP + toml.dumps(things) + SEPARATOR_END + after
data = before + SEPARATOR_START + HELP + \
toml.dumps(things) + SEPARATOR_END + after
with open('Cargo.toml', 'w') as f:
f.write(data)
# ========= Update src/tick.rs
with open('src/tick.rs', 'w') as f:
f.write('// Generated by gen_tick.py. DO NOT EDIT.\n\n')
for hz in ticks:
f.write(f'#[cfg(feature = "tick-hz-{hz:_}")] pub const TICK_HZ: u64 = {hz:_};\n')
f.write(
f'#[cfg(feature = "tick-hz-{hz:_}")] pub const TICK_HZ: u64 = {hz:_};\n')
f.write('#[cfg(not(any(\n')
for hz in ticks:
f.write(f'feature = "tick-hz-{hz:_}",\n')
f.write(')))] pub const TICK_HZ: u64 = 1_000_000;')
os.system('rustfmt src/tick.rs')
os.system('rustfmt src/tick.rs')

View File

@ -68,6 +68,44 @@ pub const TICK_HZ: u64 = 4_194_304;
pub const TICK_HZ: u64 = 8_388_608;
#[cfg(feature = "tick-hz-16_777_216")]
pub const TICK_HZ: u64 = 16_777_216;
#[cfg(feature = "tick-hz-2_000")]
pub const TICK_HZ: u64 = 2_000;
#[cfg(feature = "tick-hz-4_000")]
pub const TICK_HZ: u64 = 4_000;
#[cfg(feature = "tick-hz-8_000")]
pub const TICK_HZ: u64 = 8_000;
#[cfg(feature = "tick-hz-16_000")]
pub const TICK_HZ: u64 = 16_000;
#[cfg(feature = "tick-hz-32_000")]
pub const TICK_HZ: u64 = 32_000;
#[cfg(feature = "tick-hz-64_000")]
pub const TICK_HZ: u64 = 64_000;
#[cfg(feature = "tick-hz-128_000")]
pub const TICK_HZ: u64 = 128_000;
#[cfg(feature = "tick-hz-256_000")]
pub const TICK_HZ: u64 = 256_000;
#[cfg(feature = "tick-hz-512_000")]
pub const TICK_HZ: u64 = 512_000;
#[cfg(feature = "tick-hz-1_024_000")]
pub const TICK_HZ: u64 = 1_024_000;
#[cfg(feature = "tick-hz-2_048_000")]
pub const TICK_HZ: u64 = 2_048_000;
#[cfg(feature = "tick-hz-4_096_000")]
pub const TICK_HZ: u64 = 4_096_000;
#[cfg(feature = "tick-hz-8_192_000")]
pub const TICK_HZ: u64 = 8_192_000;
#[cfg(feature = "tick-hz-16_384_000")]
pub const TICK_HZ: u64 = 16_384_000;
#[cfg(feature = "tick-hz-32_768_000")]
pub const TICK_HZ: u64 = 32_768_000;
#[cfg(feature = "tick-hz-65_536_000")]
pub const TICK_HZ: u64 = 65_536_000;
#[cfg(feature = "tick-hz-131_072_000")]
pub const TICK_HZ: u64 = 131_072_000;
#[cfg(feature = "tick-hz-262_144_000")]
pub const TICK_HZ: u64 = 262_144_000;
#[cfg(feature = "tick-hz-524_288_000")]
pub const TICK_HZ: u64 = 524_288_000;
#[cfg(feature = "tick-hz-2_000_000")]
pub const TICK_HZ: u64 = 2_000_000;
#[cfg(feature = "tick-hz-3_000_000")]
@ -153,6 +191,25 @@ pub const TICK_HZ: u64 = 768_000_000;
feature = "tick-hz-4_194_304",
feature = "tick-hz-8_388_608",
feature = "tick-hz-16_777_216",
feature = "tick-hz-2_000",
feature = "tick-hz-4_000",
feature = "tick-hz-8_000",
feature = "tick-hz-16_000",
feature = "tick-hz-32_000",
feature = "tick-hz-64_000",
feature = "tick-hz-128_000",
feature = "tick-hz-256_000",
feature = "tick-hz-512_000",
feature = "tick-hz-1_024_000",
feature = "tick-hz-2_048_000",
feature = "tick-hz-4_096_000",
feature = "tick-hz-8_192_000",
feature = "tick-hz-16_384_000",
feature = "tick-hz-32_768_000",
feature = "tick-hz-65_536_000",
feature = "tick-hz-131_072_000",
feature = "tick-hz-262_144_000",
feature = "tick-hz-524_288_000",
feature = "tick-hz-2_000_000",
feature = "tick-hz-3_000_000",
feature = "tick-hz-4_000_000",