Skip to content

Commit 5994eec

Browse files
committed
CI: less expensive miri tests
1 parent 24596d6 commit 5994eec

4 files changed

Lines changed: 43 additions & 22 deletions

File tree

src/stream/chain.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1255,6 +1255,10 @@ mod tests {
12551255
f64: AsPrimitive<Probability>,
12561256
i32: AsPrimitive<Probability>,
12571257
{
1258+
#[cfg(miri)]
1259+
let (amt_compressed_words, amt_symbols) =
1260+
(amt_compressed_words.min(128), amt_symbols.min(100));
1261+
12581262
let mut rng = Xoshiro256StarStar::seed_from_u64(
12591263
(amt_compressed_words as u64).rotate_left(32) ^ amt_symbols as u64,
12601264
);

src/stream/queue.rs

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1160,7 +1160,12 @@ mod tests {
11601160
f64: AsPrimitive<Probability>,
11611161
i32: AsPrimitive<Probability>,
11621162
{
1163+
#[cfg(not(miri))]
11631164
const AMT: usize = 1000;
1165+
1166+
#[cfg(miri)]
1167+
const AMT: usize = 100;
1168+
11641169
let mut symbols_gaussian = Vec::with_capacity(AMT);
11651170
let mut means = Vec::with_capacity(AMT);
11661171
let mut stds = Vec::with_capacity(AMT);
@@ -1242,21 +1247,24 @@ mod tests {
12421247

12431248
#[test]
12441249
fn seek() {
1245-
const NUM_CHUNKS: usize = 100;
1246-
const SYMBOLS_PER_CHUNK: usize = 100;
1250+
#[cfg(not(miri))]
1251+
let (num_chunks, symbols_per_chunk) = (100, 100);
1252+
1253+
#[cfg(miri)]
1254+
let (num_chunks, symbols_per_chunk) = (10, 10);
12471255

12481256
let quantizer = LeakyQuantizer::<_, _, u32, 24>::new(-100..=100);
12491257
let model = quantizer.quantize(Gaussian::new(0.0, 10.0));
12501258

12511259
let mut encoder = DefaultRangeEncoder::new();
12521260

12531261
let mut rng = Xoshiro256StarStar::seed_from_u64(123);
1254-
let mut symbols = Vec::with_capacity(NUM_CHUNKS);
1255-
let mut jump_table = Vec::with_capacity(NUM_CHUNKS);
1262+
let mut symbols = Vec::with_capacity(num_chunks);
1263+
let mut jump_table = Vec::with_capacity(num_chunks);
12561264

1257-
for _ in 0..NUM_CHUNKS {
1265+
for _ in 0..num_chunks {
12581266
jump_table.push(encoder.pos());
1259-
let chunk = (0..SYMBOLS_PER_CHUNK)
1267+
let chunk = (0..symbols_per_chunk)
12601268
.map(|_| model.quantile_function(rng.next_u32() % (1 << 24)).0)
12611269
.collect::<Vec<_>>();
12621270
encoder.encode_iid_symbols(&chunk, &model).unwrap();
@@ -1271,7 +1279,7 @@ mod tests {
12711279
// implement `Pos` due to complications at the stream end.)
12721280
for (chunk, _) in symbols.iter().zip(&jump_table) {
12731281
let decoded = decoder
1274-
.decode_iid_symbols(SYMBOLS_PER_CHUNK, &model)
1282+
.decode_iid_symbols(symbols_per_chunk, &model)
12751283
.collect::<Result<Vec<_>, _>>()
12761284
.unwrap();
12771285
assert_eq!(&decoded, chunk);
@@ -1284,13 +1292,13 @@ mod tests {
12841292
// Make sure we test jumping to beginning at least once.
12851293
0
12861294
} else {
1287-
rng.next_u32() as usize % NUM_CHUNKS
1295+
rng.next_u32() as usize % num_chunks
12881296
};
12891297

12901298
let pos_and_state = jump_table[chunk_index];
12911299
decoder.seek(pos_and_state).unwrap();
12921300
let decoded = decoder
1293-
.decode_iid_symbols(SYMBOLS_PER_CHUNK, &model)
1301+
.decode_iid_symbols(symbols_per_chunk, &model)
12941302
.collect::<Result<Vec<_>, _>>()
12951303
.unwrap();
12961304
assert_eq!(&decoded, &symbols[chunk_index])

src/stream/stack.rs

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1303,7 +1303,12 @@ mod tests {
13031303
f64: AsPrimitive<Probability>,
13041304
i32: AsPrimitive<Probability>,
13051305
{
1306+
#[cfg(not(miri))]
13061307
const AMT: usize = 1000;
1308+
1309+
#[cfg(miri)]
1310+
const AMT: usize = 100;
1311+
13071312
let mut symbols_gaussian = Vec::with_capacity(AMT);
13081313
let mut means = Vec::with_capacity(AMT);
13091314
let mut stds = Vec::with_capacity(AMT);
@@ -1391,21 +1396,24 @@ mod tests {
13911396

13921397
#[test]
13931398
fn seek() {
1394-
const NUM_CHUNKS: usize = 100;
1395-
const SYMBOLS_PER_CHUNK: usize = 100;
1399+
#[cfg(not(miri))]
1400+
let (num_chunks, symbols_per_chunk) = (100, 100);
1401+
1402+
#[cfg(miri)]
1403+
let (num_chunks, symbols_per_chunk) = (10, 10);
13961404

13971405
let quantizer = DefaultLeakyQuantizer::new(-100..=100);
13981406
let model = quantizer.quantize(Gaussian::new(0.0, 10.0));
13991407

14001408
let mut encoder = DefaultAnsCoder::new();
14011409

14021410
let mut rng = Xoshiro256StarStar::seed_from_u64(123);
1403-
let mut symbols = Vec::with_capacity(NUM_CHUNKS);
1404-
let mut jump_table = Vec::with_capacity(NUM_CHUNKS);
1411+
let mut symbols = Vec::with_capacity(num_chunks);
1412+
let mut jump_table = Vec::with_capacity(num_chunks);
14051413
let (initial_pos, initial_state) = encoder.pos();
14061414

1407-
for _ in 0..NUM_CHUNKS {
1408-
let chunk = (0..SYMBOLS_PER_CHUNK)
1415+
for _ in 0..num_chunks {
1416+
let chunk = (0..symbols_per_chunk)
14091417
.map(|_| model.quantile_function(rng.next_u32() % (1 << 24)).0)
14101418
.collect::<Vec<_>>();
14111419
encoder.encode_iid_symbols_reverse(&chunk, &model).unwrap();
@@ -1421,7 +1429,7 @@ mod tests {
14211429
for (chunk, &(pos, state)) in symbols.iter().zip(&jump_table).rev() {
14221430
assert_eq!(seekable_decoder.pos(), (pos, state));
14231431
let decoded = seekable_decoder
1424-
.decode_iid_symbols(SYMBOLS_PER_CHUNK, &model)
1432+
.decode_iid_symbols(symbols_per_chunk, &model)
14251433
.collect::<Result<Vec<_>, _>>()
14261434
.unwrap();
14271435
assert_eq!(&decoded, chunk)
@@ -1431,11 +1439,11 @@ mod tests {
14311439

14321440
// Seek to some random offsets in the jump table and decode one chunk
14331441
for _ in 0..100 {
1434-
let chunk_index = rng.next_u32() as usize % NUM_CHUNKS;
1442+
let chunk_index = rng.next_u32() as usize % num_chunks;
14351443
let (pos, state) = jump_table[chunk_index];
14361444
seekable_decoder.seek((pos, state)).unwrap();
14371445
let decoded = seekable_decoder
1438-
.decode_iid_symbols(SYMBOLS_PER_CHUNK, &model)
1446+
.decode_iid_symbols(symbols_per_chunk, &model)
14391447
.collect::<Result<Vec<_>, _>>()
14401448
.unwrap();
14411449
assert_eq!(&decoded, &symbols[chunk_index])
@@ -1458,7 +1466,7 @@ mod tests {
14581466
for (chunk, &(pos, state)) in symbols.iter().zip(&jump_table).rev() {
14591467
assert_eq!(seekable_decoder.pos(), (pos, state));
14601468
let decoded = seekable_decoder
1461-
.decode_iid_symbols(SYMBOLS_PER_CHUNK, &model)
1469+
.decode_iid_symbols(symbols_per_chunk, &model)
14621470
.collect::<Result<Vec<_>, _>>()
14631471
.unwrap();
14641472
assert_eq!(&decoded, chunk)
@@ -1468,11 +1476,11 @@ mod tests {
14681476

14691477
// Seek to some random offsets in the jump table and decode one chunk each time.
14701478
for _ in 0..100 {
1471-
let chunk_index = rng.next_u32() as usize % NUM_CHUNKS;
1479+
let chunk_index = rng.next_u32() as usize % num_chunks;
14721480
let (pos, state) = jump_table[chunk_index];
14731481
seekable_decoder.seek((pos, state)).unwrap();
14741482
let decoded = seekable_decoder
1475-
.decode_iid_symbols(SYMBOLS_PER_CHUNK, &model)
1483+
.decode_iid_symbols(symbols_per_chunk, &model)
14761484
.collect::<Result<Vec<_>, _>>()
14771485
.unwrap();
14781486
assert_eq!(&decoded, &symbols[chunk_index])

tests/random_data.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,9 @@ fn grid() {
134134
let amts = [
135135
10,
136136
100,
137+
#[cfg(not(miri))]
137138
1000,
138-
#[cfg(not(debug_assertions))]
139+
#[cfg(not(any(miri, debug_assertions)))]
139140
10000,
140141
];
141142

0 commit comments

Comments
 (0)