[Webkit-unassigned] [Bug 94810] Vector::shrinkToFit should use realloc when canCopyWithMemcpy is true

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Tue Aug 28 11:06:04 PDT 2012


https://bugs.webkit.org/show_bug.cgi?id=94810





--- Comment #11 from Yong Li <yoli at rim.com>  2012-08-28 11:06:06 PST ---
I tested with the following code, and found that realloc() gives noticeable performance boost only on large blocks (>=1k).  It is even slower than malloc/memcpy/free solution on very small blocks. The larger the blocks are, the more performance boost realloc() gives. So it seems it is better to do this only when both old and new capacities are larger than 1k.

        double start = currentTime();
        for (int i = 0; i < 100000; ++i) {
            Vector<char> vector;
            vector.reserveCapacity(<capacity>);
            vector.resize(<size>);
            vector.shrinkToFit();
        }
        double elapsed = currentTime() - start;

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.


More information about the webkit-unassigned mailing list