21 #include <boost/shared_ptr.hpp> 22 #include <boost/intrusive_ptr.hpp> 27 using namespace boost;
28 using namespace gtsam;
32 Plain(
size_t _data) : data(_data) {}
59 int main(
int argc,
char *argv[]) {
61 size_t trials = 10000000;
63 gttic_(heap_plain_alloc_dealloc);
64 for(
size_t i=0;
i<trials; ++
i) {
68 gttoc_(heap_plain_alloc_dealloc);
70 gttic_(heap_virtual_alloc_dealloc);
71 for(
size_t i=0;
i<trials; ++
i) {
75 gttoc_(heap_virtual_alloc_dealloc);
77 gttic_(stack_plain_alloc_dealloc);
78 for(
size_t i=0;
i<trials; ++
i) {
81 gttoc_(stack_plain_alloc_dealloc);
83 gttic_(stack_virtual_alloc_dealloc);
84 for(
size_t i=0;
i<trials; ++
i) {
87 gttoc_(stack_virtual_alloc_dealloc);
89 gttic_(shared_plain_alloc_dealloc);
90 for(
size_t i=0;
i<trials; ++
i) {
91 boost::shared_ptr<Plain> obj(
new Plain(
i));
93 gttoc_(shared_plain_alloc_dealloc);
95 gttic_(shared_virtual_alloc_dealloc);
96 for(
size_t i=0;
i<trials; ++
i) {
97 boost::shared_ptr<Virtual> obj(
new Virtual(
i));
99 gttoc_(shared_virtual_alloc_dealloc);
102 gttic_(heap_plain_alloc_dealloc_call);
103 for(
size_t i=0;
i<trials; ++
i) {
108 gttoc_(heap_plain_alloc_dealloc_call);
110 gttic_(heap_virtual_alloc_dealloc_call);
111 for(
size_t i=0;
i<trials; ++
i) {
116 gttoc_(heap_virtual_alloc_dealloc_call);
118 gttic_(stack_plain_alloc_dealloc_call);
119 for(
size_t i=0;
i<trials; ++
i) {
123 gttoc_(stack_plain_alloc_dealloc_call);
125 gttic_(stack_virtual_alloc_dealloc_call);
126 for(
size_t i=0;
i<trials; ++
i) {
130 gttoc_(stack_virtual_alloc_dealloc_call);
132 gttic_(shared_plain_alloc_dealloc_call);
133 for(
size_t i=0;
i<trials; ++
i) {
134 boost::shared_ptr<Plain> obj(
new Plain(
i));
137 gttoc_(shared_plain_alloc_dealloc_call);
139 gttic_(shared_virtual_alloc_dealloc_call);
140 for(
size_t i=0;
i<trials; ++
i) {
141 boost::shared_ptr<Virtual> obj(
new Virtual(
i));
144 gttoc_(shared_virtual_alloc_dealloc_call);
146 gttic_(intrusive_virtual_alloc_dealloc_call);
147 for(
size_t i=0;
i<trials; ++
i) {
151 gttoc_(intrusive_virtual_alloc_dealloc_call);
virtual ~VirtualCounted()
VirtualCounted(size_t _data)
virtual void setData(size_t data)
void setData(size_t data)
virtual void setData(size_t data)
int main(int argc, char *argv[])
void intrusive_ptr_release(VirtualCounted *obj)
void intrusive_ptr_add_ref(VirtualCounted *obj)