Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[benchmarks] Allow zero delay #735 #736

Merged
merged 1 commit into from
Sep 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions agdb_benchmarks/src/readers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,11 @@ pub(crate) fn start_post_readers<S: StorageData + Send + Sync + 'static>(
for i in 0..config.post_readers.count {
let db = db.clone();
let limit = config.post_readers.posts;
let read_delay = Duration::from_millis(config.post_readers.delay_ms % (i + 1));
let read_delay = Duration::from_millis(if config.post_readers.delay_ms == 0 {
0
} else {
config.post_readers.delay_ms % (i + 1)
});
let reads = config.post_readers.reads_per_reader;

let handle = tokio::spawn(async move {
Expand Down Expand Up @@ -188,7 +192,11 @@ pub(crate) fn start_comment_readers<S: StorageData + Send + Sync + 'static>(

for i in 0..config.comment_readers.count {
let db = db.clone();
let read_delay = Duration::from_millis(config.comment_readers.delay_ms % (i + 1));
let read_delay = Duration::from_millis(if config.comment_readers.delay_ms == 0 {
0
} else {
config.comment_readers.delay_ms % (i + 1)
});
let reads = config.comment_readers.reads_per_reader;
let limit = config.comment_readers.comments;

Expand Down
12 changes: 10 additions & 2 deletions agdb_benchmarks/src/writers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,11 @@ pub(crate) fn start_post_writers<S: StorageData + Send + Sync + 'static>(
.map(|e| {
let id = e.id;
let db = db.clone();
let write_delay = Duration::from_millis(config.posters.delay_ms % id.0 as u64);
let write_delay = Duration::from_millis(if config.posters.delay_ms == 0 {
0
} else {
config.posters.delay_ms % id.0 as u64
});
let posts = config.posters.posts;
let title = config.posters.title.to_string();
let body = config.posters.body.to_string();
Expand Down Expand Up @@ -241,7 +245,11 @@ pub(crate) fn start_comment_writers<S: StorageData + Send + Sync + 'static>(
.map(|e| {
let id = e.id;
let db = db.clone();
let write_delay = Duration::from_millis(config.commenters.delay_ms % id.0 as u64);
let write_delay = Duration::from_millis(if config.commenters.delay_ms == 0 {
0
} else {
config.commenters.delay_ms % id.0 as u64
});
let comments = config.commenters.comments;
let body = config.commenters.body.to_string();

Expand Down