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

Fix external state in benchmarking (edit.rs) #1155

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

kanishkarj
Copy link
Contributor

This is in reference to the discussion in PR #1152. This PR fixes the external state of the iterations in the benchmarks.

@@ -72,7 +72,6 @@ fn benchmark_char_insertion_one_line_edit(b: &mut Bencher) {
let mut offset = 100;
b.iter(|| {
text.edit(offset..=offset, "a");
offset += 1;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe it still makes sense to do some loop inside the iter? we can just make it some fixed length.

Copy link
Member

@cmyr cmyr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For many of these functions we still may want to be doing a loop in the iteration, we just want to be doing it the same each time. This is the right general idea though!

@kanishkarj
Copy link
Contributor Author

Hmm, So you mean to say all the functions use the same offset update ? for eg

offset += 1

would be the offset for all the benchmarks?

@cmyr
Copy link
Member

cmyr commented Mar 29, 2019

I would use whatever they were using before, but inside an explicit loop, and having offset declared fresh on each b.iter(|| {. So we want to be doing the exact same thing inside each b.iter. (We might also want to clone over the rope in b.iter, so we're using the same underlying rope each time.)

@cmyr
Copy link
Member

cmyr commented Apr 2, 2019

@kanishkarj this is very close to mergeable if you want to update again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants