Opened 9 years ago
Closed 8 years ago
#9637 closed Bugs (fixed)
Boost.Container vector::resize() performance issue
Reported by: | Owned by: | Ion Gaztañaga | |
---|---|---|---|
Milestone: | To Be Determined | Component: | container |
Version: | Boost 1.55.0 | Severity: | Optimization |
Keywords: | Cc: |
Description
Hi,
I noticed that resize() on a boost vector is quite slow compared to the equivalent operation on a std::vector:
int size=2000000; std::vector<char, std::allocator<char> > vec; vec.resize(size); // ~500 us boost::container::vector<char, std::allocator<char> > vec2; vec2.resize(size); // ~3000 us
I've attached a test program, compiled with "g++ -O3 -o test test.cpp"
Environment:
- gcc version 4.6.4 (Ubuntu/Linaro 4.6.4-1ubuntu1~12.04)
- boost 1.55.0
(Side note: the performance is even worse when compiled with -O0).
cheers Dariush
Attachments (1)
Change History (2)
by , 9 years ago
comment:1 by , 8 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Note:
See TracTickets
for help on using tickets.
Thanks for the report. libstdc++ was using memset to initialize the array of chars. In commit (master and develop branches):
SHA-1: 5afad7cd0c5512016f9ad60e03c95e84a470ce17
Boost.Container uses memset with zero value to initialize several types including "char" values.