Skip to content

Commit

Permalink
Merge pull request #161 from ANSSI-FR/ci-permissions
Browse files Browse the repository at this point in the history
CI: add explicit permissions to workflows
  • Loading branch information
commial committed Apr 27, 2023
2 parents a0d32f3 + 3417ced commit 06ce8fa
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 23 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/bench.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
name: Benchmark PR

permissions:
contents: read
pull-requests: write

on:
pull_request:
branches: [ master ]
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/mla_release.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
name: mla release

permissions:
contents: write

on:
push:
tags:
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/mlar_release.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
name: mlar release

permissions:
contents: write

on:
push:
tags:
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/sanitize.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
name: Ensure repository healthy state over time

permissions:
contents: read

on:
push:
branches: [ master ]
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
name: Build & test

permissions:
contents: write

on:
push:
branches: [ master ]
Expand Down
38 changes: 15 additions & 23 deletions mla/benches/bench_archive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const KB: usize = 1024;
const MB: usize = 1024 * KB;

const SIZE_LIST: [usize; 4] = [KB, 64 * KB, MB, 16 * MB];
const SAMPLE_SIZE_SMALL: usize = 10;
const SAMPLE_SIZE_SMALL: usize = 20;
const LAYERS_POSSIBILITIES: [Layers; 4] = [
Layers::EMPTY,
Layers::COMPRESS,
Expand Down Expand Up @@ -105,7 +105,7 @@ pub fn writer_multiple_layers_multiple_block_size(c: &mut Criterion) {

let id = mla.start_file("file").unwrap();
group.bench_with_input(
BenchmarkId::new(format!("Layers {layers:?}"), size),
BenchmarkId::new(format!("{layers:?}"), size),
size,
|b, &_size| {
b.iter(|| mla.append_file_content(id, data.len() as u64, data.as_slice()));
Expand Down Expand Up @@ -188,12 +188,9 @@ pub fn reader_multiple_layers_multiple_block_size(c: &mut Criterion) {
group.throughput(Throughput::Bytes(*size as u64));

for layers in &LAYERS_POSSIBILITIES {
group.bench_function(
BenchmarkId::new(format!("Layers {layers:?}"), size),
move |b| {
b.iter_custom(|iters| read_one_file_by_chunk(iters, *size as u64, *layers))
},
);
group.bench_function(BenchmarkId::new(format!("{layers:?}"), size), move |b| {
b.iter_custom(|iters| read_one_file_by_chunk(iters, *size as u64, *layers))
});
}
}
group.finish();
Expand Down Expand Up @@ -232,12 +229,9 @@ pub fn reader_multiple_layers_multiple_block_size_multifiles_random(c: &mut Crit
group.throughput(Throughput::Bytes(*size as u64));

for layers in &LAYERS_POSSIBILITIES {
group.bench_function(
BenchmarkId::new(format!("Layers {layers:?}"), size),
move |b| {
b.iter_custom(|iters| iter_read_multifiles_random(iters, *size as u64, *layers))
},
);
group.bench_function(BenchmarkId::new(format!("{layers:?}"), size), move |b| {
b.iter_custom(|iters| iter_read_multifiles_random(iters, *size as u64, *layers))
});
}
}
group.finish();
Expand Down Expand Up @@ -267,21 +261,19 @@ fn iter_decompress_multifiles_linear(iters: u64, size: u64, layers: Layers) -> D
/// The full extraction is a common pattern of use of the library. This
/// benchmark helps measuring the gain of using `linear_extract`.
pub fn reader_multiple_layers_multiple_block_size_multifiles_linear(c: &mut Criterion) {
let mut group = c.benchmark_group("reader_multiple_layers_multiple_block_size_multifiles_linear");
let mut group =
c.benchmark_group("reader_multiple_layers_multiple_block_size_multifiles_linear");
// Reduce the number of sample to avoid taking too much time
group.sample_size(SAMPLE_SIZE_SMALL);
for size in SIZE_LIST.iter() {
group.throughput(Throughput::Bytes(*size as u64));

for layers in &LAYERS_POSSIBILITIES {
group.bench_function(
BenchmarkId::new(format!("LINEAR / Layers {layers:?}"), size),
move |b| {
b.iter_custom(|iters| {
iter_decompress_multifiles_linear(iters, *size as u64, *layers)
})
},
);
group.bench_function(BenchmarkId::new(format!("{layers:?}"), size), move |b| {
b.iter_custom(|iters| {
iter_decompress_multifiles_linear(iters, *size as u64, *layers)
})
});
}
}
group.finish();
Expand Down

0 comments on commit 06ce8fa

Please sign in to comment.