1270: time: add power-of-2 kHz tick rates. r=Dirbaio a=Dirbaio

Fixes #1269

bors r+

Co-authored-by: Dario Nieuwenhuis <dirbaio@dirbaio.net>
This commit is contained in:
bors[bot] 2023-03-09 22:32:51 +00:00 committed by GitHub
commit 055597063f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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-4_194_304 = []
tick-hz-8_388_608 = [] tick-hz-8_388_608 = []
tick-hz-16_777_216 = [] 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-2_000_000 = []
tick-hz-3_000_000 = [] tick-hz-3_000_000 = []
tick-hz-4_000_000 = [] tick-hz-4_000_000 = []

View file

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