On 5/18/15 1:30 PM, Timon Gehr wrote:
On 05/18/2015 08:53 PM, Andrei Alexandrescu wrote:
Beautiful statistics accumulated for the allocator instance and/or per
call location:
http://erdani.com/d/phobos-prerelease/std_experimental_allocator_stats_collector.html
https://github.com/andralex/phobos/blob/allocator/std/experimental/allocator/stats_collector.d
Destructors welcome.
Andrei
- The documentation for numAllocateOK is wrong. (Allocating zero bytes
is always successful.)
Fixed.
- bytesHighTide is not properly updated. (I suggest to just move the
check into the implementation of 'add' and be done with it.) Also, is
this really the only value where it is useful to track a maximum, or
other summaries?
Couldn't think of any, but I'm sure use will bring new ideas. In fact
for better capacity I just made Option a 64-bit value.
- The documentation is inconsistent on whether bytesContracted should be
changed in deallocate; the implementation does it. (I don't see why it
should.)
Well, in per-call stats I "reuse" it for counting calls to deallocate. I
clarified that in the documentation. I could add another one, but
bytesUsed is redundant with bytesAllocated - bytesDeallocated (the
latter doesn't exist) and redundancy sux. Then bytesUsed is very useful
because it's easy to think about ("how many bytes I'm currently using").
- 'static struct Voldermort'
Ouch.
- I think line 602 is not what you wanted.
'if (!s.next && root != &s)'
!s.next <-> 's' has not been added, or it is the last element of the
list
root != &s <-> 's' is not the first element of the list
I.e. if 's' is the last element of a list that contains more than one
element, the list will become cyclic.
That explains a number of things :o). Fixed.
Thanks!
Andrei