You are not logged in. You can browse in the PowerBASIC Community, but you must click Login (top right) before you can post. If this is your first visit, check out the FAQ or Sign Up.
I tested the Heap* functions and CoTaskMem* functions on my
PII 400 MHz 256MB Ram and got interesting results. CoTaskMem*
is faster than the Heap* functions using allocation of 1024 bytes
for allocations larger than 1024 bytes.
Interestingly the results are identical using allocations of
512 bytes until 8Kb - 32Kb is allocated where CoTaskMemAlloc
is faster. It leads me to think that CoTaskMemAlloc does use
the HeapFunctions for smaller allocations. However CoTaskMemAlloc
probably uses pooled virtual memory for larger allocations
(see the results for 16Kb and 32Kb with 512 byte allocation).
CoTaskMemAlloc seems to be very efficient. I'll post some tests
using CoGetMalloc as soon as I get the time.
Here are the results but they are to be taken with a pinch of salt
since a series of timing runs shows large fluctuations across
calls - it depends on the state of the system.
Addendum: I forgot to mention that the Heap* functions were tested with
%HEAP_ZERO_MEMORY OR %HEAP_NO_SERIALIZE so the comparison only is
only valid for that combination.
1024 byte allocation granularity results
---------------------------------------------------------------------
Heap:
Size = 1 Kb: 39.062500 ms per 1000 HeapAlloc/Free; total 1280 ms
Size = 2 Kb: 74.218750 ms per 1000 HeapAlloc/Free; total 1216 ms
Size = 4 Kb: 46.875000 ms per 1000 HeapAlloc/Free; total 384 ms
Size = 8 Kb: 46.875000 ms per 1000 HeapAlloc/Free; total 192 ms
Size = 16 Kb: 562.500000 ms per 1000 HeapAlloc/Free; total 1152 ms
Size = 32 Kb: 437.500000 ms per 1000 HeapAlloc/Free; total 448 ms
Size = 64 Kb: 625.000000 ms per 1000 HeapAlloc/Free; total 320 ms
CoTaskMemAlloc:
Size = 1 Kb: 66.406250 ms per 1000 CoTaskMemAlloc/Free; total 2176 ms
Size = 2 Kb: 74.218750 ms per 1000 CoTaskMemAlloc/Free; total 1216 ms
Size = 4 Kb: 31.250000 ms per 1000 CoTaskMemAlloc/Free; total 256 ms
Size = 8 Kb: 31.250000 ms per 1000 CoTaskMemAlloc/Free; total 128 ms
Size = 16 Kb: 468.750000 ms per 1000 CoTaskMemAlloc/Free; total 960 ms
Size = 32 Kb: 187.500000 ms per 1000 CoTaskMemAlloc/Free; total 192 ms
Size = 64 Kb: 125.000000 ms per 1000 CoTaskMemAlloc/Free; total 64 ms
512 byte allocation granularity results
-------------------------------------------------------------------
Heap:
Size = 512 b: 15.625000 ms per 1000 HeapAlloc/Free; total 256 ms
Size = 1 Kb: 15.625000 ms per 1000 HeapAlloc/Free; total 128 ms
Size = 2 Kb: 31.250000 ms per 1000 HeapAlloc/Free; total 128 ms
Size = 4 Kb: 0.000000 ms per 1000 HeapAlloc/Free; total 0 ms
Size = 8 Kb: 250.000000 ms per 1000 HeapAlloc/Free; total 256 ms
Size = 16 Kb: 250.000000 ms per 1000 HeapAlloc/Free; total 128 ms
Size = 32 Kb: 250.000000 ms per 1000 HeapAlloc/Free; total 64 ms
CoTaskMemAlloc
Size = 512 b: 15.625000 ms per 1000 CoTaskMemAlloc/Free; total 256 ms
Size = 1 Kb: 15.625000 ms per 1000 CoTaskMemAlloc/Free; total 128 ms
Size = 2 Kb: 15.625000 ms per 1000 CoTaskMemAlloc/Free; total 64 ms
Size = 4 Kb: 31.250000 ms per 1000 CoTaskMemAlloc/Free; total 64 ms
Size = 8 Kb: 0.000000 ms per 1000 CoTaskMemAlloc/Free; total 0 ms
Size = 16 Kb: 125.000000 ms per 1000 CoTaskMemAlloc/Free; total 64 ms
Size = 32 Kb: 0.000000 ms per 1000 CoTaskMemAlloc/Free; total 0 ms
[This message has been edited by Florent Heyworth (edited October 04, 2000).]
We process personal data about users of our site, through the use of cookies and other technologies, to deliver our services, and to analyze site activity. For additional details, refer to our Privacy Policy.
By clicking "I AGREE" below, you agree to our Privacy Policy and our personal data processing and cookie practices as described therein. You also acknowledge that this forum may be hosted outside your country and you consent to the collection, storage, and processing of your data in the country where this forum is hosted.
Comment