Leopold Toetsch wrote:
> Appended is a test program that shows timings (i386 w rdtsc) and
> the limit, where malloc changes strategy to use mmap and returns
> zeroed memory.
I don't know if it helps, but there are the results on my machine,
using Windows XP Pro and Cygwin 1.3.10 and GCC 2.95.3:
# gcc -o chkm chkm.c -O3 && ./chkm
size 1.mal 2.mal 3.mal memset clean
1 8500 1188 932 0 0
2 8908 932 892 664 **
4 6828 904 928 276 **
8 6828 904 936 276 **
16 10520 968 928 612 **
32 8796 908 912 840 **
64 8092 988 916 892 **
128 7584 1032 936 932 **
256 6328 1052 936 1088 **
512 6952 1236 940 1096 **
1024 81784 1408 944 1912 **
2048 55984 1108 944 3940 **
4096 53812 13592 1044 7928 **
8192 51976 15932 980 28880 **
16384 56988 15520 996 70516 **
32768 60780 16584 952 159332 **
65536 60876 16580 1104 356616 **
131072 62492 16440 964 748300 **
262144 68668 17628 996 1545984 **
524288 69152 17604 924 3272504 **
1048576 74324 38948 992 6678812 **
2097152 86604 38012 1052 14211056 **
4194304 106172 40908 1060 458976804 **
8388608 147276 74432 1144 56008064 **
# gcc -o chkm chkm.c malloc.c -O3 && ./chkm
size 1.mal 2.mal 3.mal memset clean
1 7104 300 204 0 0
2 3964 188 180 0 0
4 3304 188 180 0 0
8 3264 256 172 0 0
16 6508 164 180 0 0
32 2112 388 168 1500 **
64 3496 260 192 904 **
128 3268 208 296 1304 **
256 3276 392 272 1232 **
512 1924 492 196 1344 **
1024 2664 78572 268 1676 **
2048 3036 31248 116 3420 **
4096 63312 14524 144 6588 **
8192 54508 15632 116 26584 **
16384 52724 14888 172 73844 **
32768 58336 14632 164 165624 **
65536 57680 14344 164 421396 **
131072 58164 15748 236 757964 **
262144 249528 49220 49836 0 0
524288 160816 72180 53728 0 0
1048576 173212 71464 66964 0 0
2097152 214488 95112 98340 0 0
4194304 296548 171728 161160 0 0
8388608 405532 283444 291892 0 0
to compile with Visual C++ I had to change the rdtscl macro to:
#define rdtscl(low) \
{ \
_asm rdtsc \
_asm mov dword ptr [low], eax \
}
the low word seems to be in eax instead of edx, don't know why.
and these are the results:
# cl -nologo -o chkm_vc.exe chkm_vc.c && chkm_vc
chkm_vc.c
size 1.mal 2.mal 3.mal memset clean
1 2288 668 352 0 0
2 5068 456 348 176 **
4 2040 552 304 260 **
8 1936 380 280 172 **
16 2864 368 296 172 **
32 1408 756 328 172 **
64 1360 408 308 188 **
128 1260 500 376 228 **
256 1276 828 396 292 **
512 1424 400 304 568 **
1024 3936 1080 420 1168 **
2048 39664 432 388 4492 **
4096 49412 12760 420 7684 **
8192 42512 15484 524 15476 **
16384 67436 26780 544 75100 **
32768 43680 25584 532 167956 **
65536 46392 26052 125328 359224 **
131072 57456 26324 27228 788760 **
262144 52196 116656 26800 1598200 **
524288 58720 29900 17500 0 0
1048576 26504 16048 15168 0 0
2097152 38564 27296 15904 0 0
4194304 34008 27608 15804 0 0
8388608 40480 24464 25492 0 0
the results are apparently the same with -Ox (maximum opts).
cheers,
Aldo
__END__
$_=q,just perl,,s, , another ,,s,$, hacker,,print;