-
Notifications
You must be signed in to change notification settings - Fork 134
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #618 from Nukesor/compression-benchmarks
Compression benchmarks
- Loading branch information
Showing
8 changed files
with
302 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ ignore: | |
- "LICENSE" | ||
- ".github" | ||
- ".gitignore" | ||
- "pueue/benches" | ||
|
||
coverage: | ||
status: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
use std::{collections::HashMap, env::vars, path::PathBuf}; | ||
|
||
use chrono::Local; | ||
use criterion::{Criterion, criterion_group, criterion_main}; | ||
use pueue::daemon::internal_state::state::InternalState; | ||
use pueue_lib::{Settings, Task, state::PUEUE_DEFAULT_GROUP}; | ||
|
||
/// Create a large state file with a few hundred tasks. | ||
/// Save it to disk in compressed state | ||
fn save_compressed_state() { | ||
let dir = tempfile::tempdir().unwrap(); | ||
let mut settings = Settings::default(); | ||
settings.shared.pueue_directory = Some(dir.path().to_owned()); | ||
settings.daemon.compress_state_file = true; | ||
|
||
let mut state = InternalState::new(); | ||
|
||
for _ in 0..400 { | ||
let task = Task::new( | ||
"ls".into(), | ||
PathBuf::from("/tmp"), | ||
HashMap::from_iter(vars()), | ||
PUEUE_DEFAULT_GROUP.to_owned(), | ||
pueue_lib::TaskStatus::Queued { | ||
enqueued_at: Local::now(), | ||
}, | ||
Vec::new(), | ||
0, | ||
None, | ||
); | ||
|
||
state.add_task(task); | ||
} | ||
|
||
state.save(&settings).unwrap(); | ||
} | ||
|
||
pub fn state(crit: &mut Criterion) { | ||
crit.bench_function("Save compressed state", |b| b.iter(save_compressed_state)); | ||
} | ||
|
||
criterion_group!(benches, state); | ||
criterion_main!(benches); |
Oops, something went wrong.