-
Notifications
You must be signed in to change notification settings - Fork 24
Add copy trackers in tests #651
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
Changes from 10 commits
3c295c3
6544ec7
4599a05
bade9c9
c671b9a
f180352
6e015c9
3246b41
3eeb83c
46e8ac1
9ab0734
86aaf71
820b3af
63fa9ab
0529bfb
7cc985d
57dc3b8
a136355
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,6 +24,7 @@ | |
| #include <type_traits> | ||
|
|
||
| #include "sparrow/buffer/allocator.hpp" | ||
| #include "sparrow/debug/copy_tracker.hpp" | ||
| #include "sparrow/details/3rdparty/xsimd_aligned_allocator.hpp" | ||
| #include "sparrow/utils/contracts.hpp" | ||
| #include "sparrow/utils/iterator.hpp" | ||
|
|
@@ -35,6 +36,15 @@ | |
|
|
||
| namespace sparrow | ||
| { | ||
| namespace copy_tracker | ||
| { | ||
| template <typename T> | ||
| std::string key_buffer() | ||
| { | ||
| return "buffer<" + std::string(typeid(T).name()) + ">"; | ||
| } | ||
|
Comment on lines
45
to
52
|
||
| } | ||
|
|
||
| template <typename T> | ||
| concept is_buffer_view = requires(T t) { typename T::is_buffer_view; }; | ||
|
|
||
|
|
@@ -490,6 +500,7 @@ namespace sparrow | |
| this->create_storage(rhs.size()); | ||
| get_data().p_end = copy_initialize(rhs.begin(), rhs.end(), get_data().p_begin, get_allocator()); | ||
| } | ||
| copy_tracker::increase(copy_tracker::key_buffer<T>()); | ||
| } | ||
|
|
||
| template <class T> | ||
|
|
@@ -502,6 +513,7 @@ namespace sparrow | |
| this->create_storage(rhs.size()); | ||
| get_data().p_end = copy_initialize(rhs.begin(), rhs.end(), get_data().p_begin, get_allocator()); | ||
| } | ||
| copy_tracker::increase(copy_tracker::key_buffer<T>()); | ||
|
||
| } | ||
|
|
||
| template <class T> | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -15,10 +15,20 @@ | |||||||||||||
| #pragma once | ||||||||||||||
|
|
||||||||||||||
| #include "sparrow/buffer/buffer.hpp" | ||||||||||||||
| #include "sparrow/debug/copy_tracker.hpp" | ||||||||||||||
| #include "sparrow/utils/contracts.hpp" | ||||||||||||||
|
|
||||||||||||||
| namespace sparrow | ||||||||||||||
| { | ||||||||||||||
| namespace copy_tracker | ||||||||||||||
| { | ||||||||||||||
| template <class T> | ||||||||||||||
| std::string key_buffer_view() | ||||||||||||||
|
||||||||||||||
| { | ||||||||||||||
| return "buffer_view<" + std::string(typeid(T).name()) + ">"; | ||||||||||||||
| } | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| /* | ||||||||||||||
| * Non-owning view of a contiguous sequence of objects of type T. | ||||||||||||||
| * | ||||||||||||||
|
|
@@ -48,6 +58,10 @@ namespace sparrow | |||||||||||||
| using const_reverse_iterator = std::reverse_iterator<const_iterator>; | ||||||||||||||
|
|
||||||||||||||
| constexpr buffer_view() = default; | ||||||||||||||
| constexpr buffer_view(const buffer_view&); | ||||||||||||||
| constexpr buffer_view(buffer_view&&) noexcept = default; | ||||||||||||||
| constexpr buffer_view& operator=(const buffer_view&) = default; | ||||||||||||||
| constexpr buffer_view& operator=(buffer_view&&) noexcept = default; | ||||||||||||||
| constexpr explicit buffer_view(buffer<T>& buffer) | ||||||||||||||
| requires(!std::is_const_v<T>); | ||||||||||||||
| template <class U> | ||||||||||||||
|
|
@@ -116,6 +130,14 @@ namespace sparrow | |||||||||||||
| * buffer_view implementation * | ||||||||||||||
| ******************************/ | ||||||||||||||
|
|
||||||||||||||
| template <class T> | ||||||||||||||
| constexpr buffer_view<T>::buffer_view(const buffer_view& other) | ||||||||||||||
| : p_data(other.p_data) | ||||||||||||||
| , m_size(other.m_size) | ||||||||||||||
| { | ||||||||||||||
| copy_tracker::increase(copy_tracker::key_buffer_view<T>()); | ||||||||||||||
|
||||||||||||||
| { | |
| copy_tracker::increase(copy_tracker::key_buffer_view<T>()); | |
| { | |
| #if defined(SPARROW_TRACK_COPIES) | |
| copy_tracker::increase(copy_tracker::key_buffer_view<T>()); | |
| #endif |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should also increase copies number in operator=
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about keeping the generic name
keyand constrain the template, like you did forprimitive_array_impl?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done