diff --git a/benchmark/string.cpp b/benchmark/string.cpp index 0e438519..d507a2fe 100644 --- a/benchmark/string.cpp +++ b/benchmark/string.cpp @@ -200,7 +200,7 @@ template struct allocator T* allocate( std::size_t n ) const { - s_alloc_bytes += n; + s_alloc_bytes += n * sizeof(T); s_alloc_count++; return std::allocator().allocate( n ); @@ -208,7 +208,7 @@ template struct allocator void deallocate( T* p, std::size_t n ) const noexcept { - s_alloc_bytes -= n; + s_alloc_bytes -= n * sizeof(T); s_alloc_count--; std::allocator().deallocate( p, n ); @@ -392,7 +392,7 @@ int main() for( auto const& x: times ) { - std::cout << std::setw( 30 ) << ( x.label_ + ": " ) << std::setw( 5 ) << x.time_ << " ms, " << std::setw( 8 ) << x.bytes_ << " bytes in " << x.count_ << " allocations\n"; + std::cout << std::setw( 30 ) << ( x.label_ + ": " ) << std::setw( 5 ) << x.time_ << " ms, " << std::setw( 9 ) << x.bytes_ << " bytes in " << x.count_ << " allocations\n"; } } diff --git a/benchmark/uint32.cpp b/benchmark/uint32.cpp index 241b94d2..f983a05a 100644 --- a/benchmark/uint32.cpp +++ b/benchmark/uint32.cpp @@ -216,7 +216,7 @@ template struct allocator T* allocate( std::size_t n ) const { - s_alloc_bytes += n; + s_alloc_bytes += n * sizeof(T); s_alloc_count++; return std::allocator().allocate( n ); @@ -224,7 +224,7 @@ template struct allocator void deallocate( T* p, std::size_t n ) const noexcept { - s_alloc_bytes -= n; + s_alloc_bytes -= n * sizeof(T); s_alloc_count--; std::allocator().deallocate( p, n ); @@ -330,7 +330,7 @@ int main() for( auto const& x: times ) { - std::cout << std::setw( 25 ) << ( x.label_ + ": " ) << std::setw( 5 ) << x.time_ << " ms, " << std::setw( 8 ) << x.bytes_ << " bytes in " << x.count_ << " allocations\n"; + std::cout << std::setw( 25 ) << ( x.label_ + ": " ) << std::setw( 5 ) << x.time_ << " ms, " << std::setw( 9 ) << x.bytes_ << " bytes in " << x.count_ << " allocations\n"; } } diff --git a/benchmark/uint64.cpp b/benchmark/uint64.cpp index eb1906fd..93401f2b 100644 --- a/benchmark/uint64.cpp +++ b/benchmark/uint64.cpp @@ -216,7 +216,7 @@ template struct allocator T* allocate( std::size_t n ) const { - s_alloc_bytes += n; + s_alloc_bytes += n * sizeof(T); s_alloc_count++; return std::allocator().allocate( n ); @@ -224,7 +224,7 @@ template struct allocator void deallocate( T* p, std::size_t n ) const noexcept { - s_alloc_bytes -= n; + s_alloc_bytes -= n * sizeof(T); s_alloc_count--; std::allocator().deallocate( p, n ); @@ -330,7 +330,7 @@ int main() for( auto const& x: times ) { - std::cout << std::setw( 25 ) << ( x.label_ + ": " ) << std::setw( 5 ) << x.time_ << " ms, " << std::setw( 8 ) << x.bytes_ << " bytes in " << x.count_ << " allocations\n"; + std::cout << std::setw( 25 ) << ( x.label_ + ": " ) << std::setw( 5 ) << x.time_ << " ms, " << std::setw( 9 ) << x.bytes_ << " bytes in " << x.count_ << " allocations\n"; } }