Skip to content

bench and optimize from_slice #118

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

Merged
merged 1 commit into from
Aug 22, 2018
Merged

Conversation

llogiq
Copy link
Contributor

@llogiq llogiq commented Aug 22, 2018

This adds "bench_from_slice(_vec)(_small)" benches, renaming the previous versions to "bench_from_iter*" (because they were using From<&[T]>, which calls FromIterator internally) and optimizes the from_slice constructor considerably.

Before:

test bench_from_slice                  ... bench:          42 ns/iter (+/- 0)
test bench_from_slice_small            ... bench:          12 ns/iter (+/- 0)

After:

test bench_from_slice                  ... bench:          27 ns/iter (+/- 0)
test bench_from_slice_small            ... bench:           8 ns/iter (+/- 0)

This change is Reviewable

@llogiq
Copy link
Contributor Author

llogiq commented Aug 22, 2018

travis error is unrelated – current nightly fails to build master as well.

@mbrubeck
Copy link
Collaborator

@bors-servo r+

@bors-servo
Copy link
Contributor

📌 Commit 2894fc5 has been approved by mbrubeck

bors-servo pushed a commit that referenced this pull request Aug 22, 2018
bench and optimize `from_slice`

This adds "bench_from_slice(_vec)(_small)" benches, renaming the previous versions to "bench_from_iter*" (because they were using `From<&[T]>`, which calls `FromIterator` internally) and optimizes the `from_slice` constructor considerably.

Before:
```
test bench_from_slice                  ... bench:          42 ns/iter (+/- 0)
test bench_from_slice_small            ... bench:          12 ns/iter (+/- 0)
```
After:
```
test bench_from_slice                  ... bench:          27 ns/iter (+/- 0)
test bench_from_slice_small            ... bench:           8 ns/iter (+/- 0)
```

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/rust-smallvec/118)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

⌛ Testing commit 2894fc5 with merge 2aa599d...

@bors-servo
Copy link
Contributor

💔 Test failed - status-travis

@mbrubeck
Copy link
Collaborator

Looks like this needs a #[cfg(not(feature = "std"))] use alloc::borrow::ToOwned;.

@llogiq llogiq force-pushed the optimize-from-slice branch from 2894fc5 to b0c7dd1 Compare August 22, 2018 17:46
@llogiq
Copy link
Contributor Author

llogiq commented Aug 22, 2018

I'll settle for .to_vec() instead.

@llogiq llogiq force-pushed the optimize-from-slice branch from b0c7dd1 to 0801880 Compare August 22, 2018 20:10
This adds "bench_from_slice(_vec)(_small)" benches, renaming the previous
versions to "bench_from_iter*" (because they were using `From<&[T]>`, which
calls `FromIterator` internally) and optimizes the `from_slice` constructor
considerably.

Before:
```
test bench_from_slice                  ... bench:          42 ns/iter (+/- 0)
test bench_from_slice_small            ... bench:          12 ns/iter (+/- 0)
```
After:
```
test bench_from_slice                  ... bench:          27 ns/iter (+/- 0)
test bench_from_slice_small            ... bench:           8 ns/iter (+/- 0)
```
@llogiq llogiq force-pushed the optimize-from-slice branch from 0801880 to 7633aeb Compare August 22, 2018 20:14
@llogiq
Copy link
Contributor Author

llogiq commented Aug 22, 2018

@mbrubeck this is ready to merge now.

Also perhaps we could get a new version out now that rustc is going to use it...

@mbrubeck
Copy link
Collaborator

@bors-servo r+

@bors-servo
Copy link
Contributor

📌 Commit 7633aeb has been approved by mbrubeck

@bors-servo
Copy link
Contributor

⌛ Testing commit 7633aeb with merge dc6c0ac...

bors-servo pushed a commit that referenced this pull request Aug 22, 2018
bench and optimize `from_slice`

This adds "bench_from_slice(_vec)(_small)" benches, renaming the previous versions to "bench_from_iter*" (because they were using `From<&[T]>`, which calls `FromIterator` internally) and optimizes the `from_slice` constructor considerably.

Before:
```
test bench_from_slice                  ... bench:          42 ns/iter (+/- 0)
test bench_from_slice_small            ... bench:          12 ns/iter (+/- 0)
```
After:
```
test bench_from_slice                  ... bench:          27 ns/iter (+/- 0)
test bench_from_slice_small            ... bench:           8 ns/iter (+/- 0)
```

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/rust-smallvec/118)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

☀️ Test successful - status-travis
Approved by: mbrubeck
Pushing dc6c0ac to master...

@bors-servo bors-servo merged commit 7633aeb into servo:master Aug 22, 2018
mbrubeck added a commit to mbrubeck/rust-smallvec that referenced this pull request Aug 22, 2018
Change log:

* servo#118 - optimize `from_slice`
* servo#115 - add `into_inner` method
* Some code cleanup and testing improvements (servo#112, servo#113, servo#114, servo#120)
mbrubeck added a commit to mbrubeck/rust-smallvec that referenced this pull request Aug 22, 2018
Change log:

* servo#115 - add `into_inner` method
* servo#117 - add `from_buf_and_len` and `from_buf_and_len_unchecked`
* servo#118 - optimize `from_slice`
* Some code cleanup and testing improvements (servo#112, servo#113, servo#114, servo#120)
@mbrubeck mbrubeck mentioned this pull request Aug 22, 2018
bors-servo pushed a commit that referenced this pull request Aug 22, 2018
Version 0.6.5

Change log:

* #115 - add `into_inner` method
* #117 - add `from_buf_and_len` and `from_buf_and_len_unchecked`
* #118 - optimize `from_slice`
* Some code cleanup and testing improvements (#112, #113, #114, #120)

cc @llogiq

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/rust-smallvec/121)
<!-- Reviewable:end -->
@llogiq llogiq deleted the optimize-from-slice branch August 23, 2018 04:16
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.

4 participants