News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

ZeroMemory Speed Test!

Started by ecube, January 23, 2007, 03:32:37 AM

Previous topic - Next topic

ecube

zero_it - hutch: 3156
xzero_it - The Dude of Dudes: 151
xzero_it2 - pro3carp3: 163
RtlZeroMemory - Microsoft: 151
ZeroMemD - unknown: 169
fZeroMemory- Four-F: 163



[attachment deleted by admin]

jdoe

I have added mine "AzmtMemZero". The timing is not so bad on my AMD Athlon.


zero_it - hutch: 3116
xzero_it - The Dude of Dudes: 282
xzero_it2 - pro3carp3: 294
RtlZeroMemory - Microsoft: 284
ZeroMemD - unknown: 300
fZeroMemory- Four-F: 295
AzmtMemZero: 219




[attachment deleted by admin]

u


zero_it - hutch: 3241
xzero_it - The Dude of Dudes: 153
xzero_it2 - pro3carp3: 168
RtlZeroMemory - Microsoft: 154
ZeroMemD - unknown: 173
fZeroMemory- Four-F: 166
AzmtMemZero: 224

Sempron 3000+, DDR400
Please use a smaller graphic in your signature.

TNick

Quotezero_it - hutch: 1996
xzero_it - The Dude of Dudes: 443
xzero_it2 - pro3carp3: 454
RtlZeroMemory - Microsoft: 448
ZeroMemD - unknown: 460
fZeroMemory- Four-F: 455
AzmtMemZero: 550

on Intel Celeron 2.53 GHz, 512MB  memory

j_groothu

Intel PIV (Northwood) @ 2GHz
zero_it - hutch: 2003
xzero_it - The Dude of Dudes: 398
xzero_it2 - pro3carp3: 451
RtlZeroMemory - Microsoft: 407
ZeroMemD - unknown: 464
fZeroMemory- Four-F: 447
AzmtMemZero: 548

mnemonic

WinXP Home (32bit) @ Turion64 2GHz
zero_it - hutch: 3142
xzero_it - The Dude of Dudes: 151
xzero_it2 - pro3carp3: 160
RtlZeroMemory - Microsoft: 148
ZeroMemD - unknown: 167
fZeroMemory- Four-F: 160
AzmtMemZero: 218
Be kind. Everyone you meet is fighting a hard battle.--Plato
-------
How To Ask Questions The Smart Way

hutch--

This is a 2am quick play. I added the memfill proc from the masm32 library and set the timings to run 4 different lengths of fills. REP STOSD is difficult to beat at 1k and over but easy to beat under 1k. I removed the stack frame from the byte version but it will not compete with DWORD versions over very short byte counts.

Here are the timings I get from the tweaked test piece. Note that I fixed both Dude's and pro3carp3's version as they modified EDI without preserving it.


; ------------- Sample size = 16 bytes ---------------------
zero_it - hutch: 49
xzero_it - The Dude of Dudes: 88
xzero_it2 - pro3carp3: 118
RtlZeroMemory - Microsoft: 99
ZeroMemD - unknown: 126
fZeroMemory- Four-F: 112
memfill - masm32 lib: 13
; ------------- Sample size = 64 bytes ---------------------
zero_it - hutch: 148
xzero_it - The Dude of Dudes: 110
xzero_it2 - pro3carp3: 138
RtlZeroMemory - Microsoft: 120
ZeroMemD - unknown: 147
fZeroMemory- Four-F: 132
memfill - masm32 lib: 32
; ------------- Sample size = 256 bytes ---------------------
zero_it - hutch: 535
xzero_it - The Dude of Dudes: 237
xzero_it2 - pro3carp3: 271
RtlZeroMemory - Microsoft: 238
ZeroMemD - unknown: 285
fZeroMemory- Four-F: 269
memfill - masm32 lib: 147
; ------------- Sample size = 1024 bytes ---------------------
zero_it - hutch: 2071
xzero_it - The Dude of Dudes: 422
xzero_it2 - pro3carp3: 453
RtlZeroMemory - Microsoft: 429
ZeroMemD - unknown: 469
fZeroMemory- Four-F: 451
memfill - masm32 lib: 579
Press any key to continue ...

[attachment deleted by admin]
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

TNick

Quote; ------------- Sample size = 16 bytes ---------------------
zero_it - hutch: 40
xzero_it - The Dude of Dudes: 76
xzero_it2 - pro3carp3: 86
RtlZeroMemory - Microsoft: 79
ZeroMemD - unknown: 92
fZeroMemory- Four-F: 84
memfill - masm32 lib: 26
; ------------- Sample size = 64 bytes ---------------------
zero_it - hutch: 161
xzero_it - The Dude of Dudes: 98
xzero_it2 - pro3carp3: 112
RtlZeroMemory - Microsoft: 102
ZeroMemD - unknown: 118
fZeroMemory- Four-F: 110
memfill - masm32 lib: 39
; ------------- Sample size = 256 bytes ---------------------
zero_it - hutch: 511
xzero_it - The Dude of Dudes: 292
xzero_it2 - pro3carp3: 301
RtlZeroMemory - Microsoft: 299
ZeroMemD - unknown: 312
fZeroMemory- Four-F: 303
memfill - masm32 lib: 136
; ------------- Sample size = 1024 bytes ---------------------
zero_it - hutch: 1994
xzero_it - The Dude of Dudes: 452
xzero_it2 - pro3carp3: 454
RtlZeroMemory - Microsoft: 447
ZeroMemD - unknown: 471
fZeroMemory- Four-F: 457
memfill - masm32 lib: 572

still on Intel Celeron 2.53 GHz, 512MB  memory :)

GregL

PIII 1GHz

; ------------- Sample size = 16 bytes ---------------------
zero_it - hutch: 49
xzero_it - The Dude of Dudes: 41
xzero_it2 - pro3carp3: 52
RtlZeroMemory - Microsoft: 33
ZeroMemD - unknown: 56
fZeroMemory- Four-F: 60
memfill - masm32 lib: 22
; ------------- Sample size = 64 bytes ---------------------
zero_it - hutch: 146
xzero_it - The Dude of Dudes: 67
xzero_it2 - pro3carp3: 80
RtlZeroMemory - Microsoft: 61
ZeroMemD - unknown: 82
fZeroMemory- Four-F: 89
memfill - masm32 lib: 33
; ------------- Sample size = 256 bytes ---------------------
zero_it - hutch: 534
xzero_it - The Dude of Dudes: 206
xzero_it2 - pro3carp3: 221
RtlZeroMemory - Microsoft: 204
ZeroMemD - unknown: 224
fZeroMemory- Four-F: 222
memfill - masm32 lib: 103
; ------------- Sample size = 1024 bytes ---------------------
zero_it - hutch: 2081
xzero_it - The Dude of Dudes: 333
xzero_it2 - pro3carp3: 347
RtlZeroMemory - Microsoft: 331
ZeroMemD - unknown: 351
fZeroMemory- Four-F: 350
memfill - masm32 lib: 338


j_groothu

PIV ( Northwood) @2GHz ( new test )
; ------------- Sample size = 16 bytes ---------------------
zero_it - hutch: 47
xzero_it - The Dude of Dudes: 103
xzero_it2 - pro3carp3: 166
RtlZeroMemory - Microsoft: 112
ZeroMemD - unknown: 183
fZeroMemory- Four-F: 157
memfill - masm32 lib: 18
; ------------- Sample size = 64 bytes ---------------------
zero_it - hutch: 139
xzero_it - The Dude of Dudes: 126
xzero_it2 - pro3carp3: 179
RtlZeroMemory - Microsoft: 130
ZeroMemD - unknown: 194
fZeroMemory- Four-F: 170
memfill - masm32 lib: 32
; ------------- Sample size = 256 bytes ---------------------
zero_it - hutch: 527
xzero_it - The Dude of Dudes: 225
xzero_it2 - pro3carp3: 282
RtlZeroMemory - Microsoft: 235
ZeroMemD - unknown: 301
fZeroMemory- Four-F: 285
memfill - masm32 lib: 151
; ------------- Sample size = 1024 bytes ---------------------
zero_it - hutch: 2009
xzero_it - The Dude of Dudes: 415
xzero_it2 - pro3carp3: 473
RtlZeroMemory - Microsoft: 426
ZeroMemD - unknown: 489
fZeroMemory- Four-F: 474
memfill - masm32 lib: 566
Press any key to continue ...

Ghirai

Quote; ------------- Sample size = 16 bytes ---------------------
zero_it - hutch: 77
xzero_it - The Dude of Dudes: 36
xzero_it2 - pro3carp3: 42
RtlZeroMemory - Microsoft: 113
ZeroMemD - unknown: 66
fZeroMemory- Four-F: 58
memfill - masm32 lib: 39
; ------------- Sample size = 64 bytes ---------------------
zero_it - hutch: 170
xzero_it - The Dude of Dudes: 54
xzero_it2 - pro3carp3: 65
RtlZeroMemory - Microsoft: 116
ZeroMemD - unknown: 70
fZeroMemory- Four-F: 61
memfill - masm32 lib: 41
; ------------- Sample size = 256 bytes ---------------------
zero_it - hutch: 587
xzero_it - The Dude of Dudes: 77
xzero_it2 - pro3carp3: 87
RtlZeroMemory - Microsoft: 139
ZeroMemD - unknown: 91
fZeroMemory- Four-F: 84
memfill - masm32 lib: 70
; ------------- Sample size = 1024 bytes ---------------------
zero_it - hutch: 2172
xzero_it - The Dude of Dudes: 173
xzero_it2 - pro3carp3: 183
RtlZeroMemory - Microsoft: 246
ZeroMemD - unknown: 189
fZeroMemory- Four-F: 115
memfill - masm32 lib: 203

Dunno if the test if of any use, it was ran on wine in FreeBSD on a Sempron 2500+  :red

However, it seems to be faster than the original MS code :bg
MASM32 Project/RadASM mirror - http://ghirai.com/hutch/mmi.html

ecube

#11
I added jdoes AzmtMemZero, RtlFillMemory, and tried to add crt_memset, but the crt one wouldn't compile. Also my specs are amd 64 3800, 2 gigs ddr ram

; ------------- Sample size = 16 bytes ---------------------
zero_it - hutch: 51
xzero_it - The Dude of Dudes: 26
xzero_it2 - pro3carp3: 39
RtlZeroMemory - Microsoft: 24
ZeroMemD - unknown: 43
fZeroMemory- Four-F: 34
memfill - masm32 lib: 16
AzmtMemZero - jdoe 15
RtlFillMemory - Microsoft(NT+ only)29
; ------------- Sample size = 64 bytes ---------------------
zero_it - hutch: 154
xzero_it - The Dude of Dudes: 31
xzero_it2 - pro3carp3: 44
RtlZeroMemory - Microsoft: 30
ZeroMemD - unknown: 49
fZeroMemory- Four-F: 42
memfill - masm32 lib: 21
AzmtMemZero - jdoe 24
RtlFillMemory - Microsoft(NT+ only)35
; ------------- Sample size = 256 bytes ---------------------
zero_it - hutch: 568
xzero_it - The Dude of Dudes: 62
xzero_it2 - pro3carp3: 71
RtlZeroMemory - Microsoft: 58
ZeroMemD - unknown: 74
fZeroMemory- Four-F: 67
memfill - masm32 lib: 53
AzmtMemZero - jdoe 67
RtlFillMemory - Microsoft(NT+ only)62
; ------------- Sample size = 1024 bytes ---------------------
zero_it - hutch: 2228
xzero_it - The Dude of Dudes: 161
xzero_it2 - pro3carp3: 173
RtlZeroMemory - Microsoft: 161
ZeroMemD - unknown: 178
fZeroMemory- Four-F: 174
memfill - masm32 lib: 196
AzmtMemZero - jdoe 232
RtlFillMemory - Microsoft(NT+ only)165

[attachment deleted by admin]

MichaelW

The problem with memset is the [esi]. The prototype in msvcrt.inc is:

c_msvcrt typedef PROTO C :VARARG
...
externdef _imp__memset:PTR c_msvcrt
    crt_memset equ <_imp__memset>

The problem might possibly have something to do with :VARARG not being preceded by a symbol. Per the MASM Programmer's Guide:

"A symbol must precede :VARARG so the procedure can access arguments as offsets from the given variable name"


       ;invoke crt_memset, addr szBuff, 0, [esi]
       push [esi]
       push 0
       push offset szBuff
       call crt_memset
       add esp,12


P3:


; ------------- Sample size = 16 bytes ---------------------
zero_it - hutch: 60
xzero_it - The Dude of Dudes: 41
xzero_it2 - pro3carp3: 52
RtlZeroMemory - Microsoft: 33
ZeroMemD - unknown: 55
fZeroMemory- Four-F: 60
memfill - masm32 lib: 19
AzmtMemZero - jdoe 44
RtlFillMemory - Microsoft(NT+ only)50
msvcrt memset - Microsoft: 41
; ------------- Sample size = 64 bytes ---------------------
zero_it - hutch: 206
xzero_it - The Dude of Dudes: 67
xzero_it2 - pro3carp3: 80
RtlZeroMemory - Microsoft: 61
ZeroMemD - unknown: 82
fZeroMemory- Four-F: 89
memfill - masm32 lib: 33
AzmtMemZero - jdoe 63
RtlFillMemory - Microsoft(NT+ only)78
msvcrt memset - Microsoft: 70
; ------------- Sample size = 256 bytes ---------------------
zero_it - hutch: 785
xzero_it - The Dude of Dudes: 208
xzero_it2 - pro3carp3: 225
RtlZeroMemory - Microsoft: 205
ZeroMemD - unknown: 224
fZeroMemory- Four-F: 226
memfill - masm32 lib: 102
AzmtMemZero - jdoe 130
RtlFillMemory - Microsoft(NT+ only)222
msvcrt memset - Microsoft: 211
; ------------- Sample size = 1024 bytes ---------------------
zero_it - hutch: 3108
xzero_it - The Dude of Dudes: 340
xzero_it2 - pro3carp3: 350
RtlZeroMemory - Microsoft: 334
ZeroMemD - unknown: 353
fZeroMemory- Four-F: 354
memfill - masm32 lib: 337
AzmtMemZero - jdoe 371
RtlFillMemory - Microsoft(NT+ only)351
msvcrt memset - Microsoft: 340


P4 Willamette:

; ------------- Sample size = 16 bytes ------------------
zero_it - hutch: 44
xzero_it - The Dude of Dudes: 96
xzero_it2 - pro3carp3: 148
RtlZeroMemory - Microsoft: 109
ZeroMemD - unknown: 158
fZeroMemory- Four-F: 142
memfill - masm32 lib: 12
AzmtMemZero - jdoe 25
RtlFillMemory - Microsoft(NT+ only)120
msvcrt memset - Microsoft: 71
; ------------- Sample size = 64 bytes ------------------
zero_it - hutch: 136
xzero_it - The Dude of Dudes: 112
xzero_it2 - pro3carp3: 172
RtlZeroMemory - Microsoft: 130
ZeroMemD - unknown: 175
fZeroMemory- Four-F: 158
memfill - masm32 lib: 38
AzmtMemZero - jdoe 32
RtlFillMemory - Microsoft(NT+ only)136
msvcrt memset - Microsoft: 87
; ------------- Sample size = 256 bytes -----------------
zero_it - hutch: 552
xzero_it - The Dude of Dudes: 212
xzero_it2 - pro3carp3: 264
RtlZeroMemory - Microsoft: 231
ZeroMemD - unknown: 274
fZeroMemory- Four-F: 258
memfill - masm32 lib: 160
AzmtMemZero - jdoe 162
RtlFillMemory - Microsoft(NT+ only)237
msvcrt memset - Microsoft: 174
; ------------- Sample size = 1024 bytes ----------------
zero_it - hutch: 1992
xzero_it - The Dude of Dudes: 382
xzero_it2 - pro3carp3: 445
RtlZeroMemory - Microsoft: 399
ZeroMemD - unknown: 447
fZeroMemory- Four-F: 434
memfill - masm32 lib: 558
AzmtMemZero - jdoe 542
RtlFillMemory - Microsoft(NT+ only)398
msvcrt memset - Microsoft: 343

eschew obfuscation

ecube

Thanks MichaelW, I updated the attachment in my last post with your fixes and heres the new listing I got


; ------------- Sample size = 16 bytes ---------------------
zero_it - hutch: 61
xzero_it - The Dude of Dudes: 23
xzero_it2 - pro3carp3: 35
RtlZeroMemory - Microsoft: 22
ZeroMemD - unknown: 40
fZeroMemory- Four-F: 32
memfill - masm32 lib: 15
AzmtMemZero - jdoe 14
RtlFillMemory - Microsoft(NT+ only)27
msvcrt memset - Microsoft 30
; ------------- Sample size = 64 bytes ---------------------
zero_it - hutch: 206
xzero_it - The Dude of Dudes: 29
xzero_it2 - pro3carp3: 41
RtlZeroMemory - Microsoft: 29
ZeroMemD - unknown: 46
fZeroMemory- Four-F: 39
memfill - masm32 lib: 19
AzmtMemZero - jdoe 23
RtlFillMemory - Microsoft(NT+ only)34
msvcrt memset - Microsoft 37
; ------------- Sample size = 256 bytes ---------------------
zero_it - hutch: 785
xzero_it - The Dude of Dudes: 53
xzero_it2 - pro3carp3: 65
RtlZeroMemory - Microsoft: 53
ZeroMemD - unknown: 70
fZeroMemory- Four-F: 63
memfill - masm32 lib: 49
AzmtMemZero - jdoe 59
RtlFillMemory - Microsoft(NT+ only)58
msvcrt memset - Microsoft 61
; ------------- Sample size = 1024 bytes ---------------------
zero_it - hutch: 3095
xzero_it - The Dude of Dudes: 150
xzero_it2 - pro3carp3: 161
RtlZeroMemory - Microsoft: 149
ZeroMemD - unknown: 166
fZeroMemory- Four-F: 159
memfill - masm32 lib: 182
AzmtMemZero - jdoe 216
RtlFillMemory - Microsoft(NT+ only)154
msvcrt memset - Microsoft 157

j_groothu

PIV ( Northwood) @2GHz
; ------------- Sample size = 16 bytes ---------------------
zero_it - hutch: 45
xzero_it - The Dude of Dudes: 103
xzero_it2 - pro3carp3: 160
RtlZeroMemory - Microsoft: 112
ZeroMemD - unknown: 181
fZeroMemory- Four-F: 156
memfill - masm32 lib: 16
AzmtMemZero - jdoe 15
RtlFillMemory - Microsoft(NT+ only)120
msvcrt memset - Microsoft 71
; ------------- Sample size = 64 bytes ---------------------
zero_it - hutch: 150
xzero_it - The Dude of Dudes: 128
xzero_it2 - pro3carp3: 286
RtlZeroMemory - Microsoft: 126
ZeroMemD - unknown: 187
fZeroMemory- Four-F: 170
memfill - masm32 lib: 31
AzmtMemZero - jdoe 36
RtlFillMemory - Microsoft(NT+ only)130
msvcrt memset - Microsoft 79
; ------------- Sample size = 256 bytes ---------------------
zero_it - hutch: 513
xzero_it - The Dude of Dudes: 230
xzero_it2 - pro3carp3: 281
RtlZeroMemory - Microsoft: 230
ZeroMemD - unknown: 298
fZeroMemory- Four-F: 278
memfill - masm32 lib: 154
AzmtMemZero - jdoe 157
RtlFillMemory - Microsoft(NT+ only)247
msvcrt memset - Microsoft 190
; ------------- Sample size = 1024 bytes ---------------------
zero_it - hutch: 1997
xzero_it - The Dude of Dudes: 393
xzero_it2 - pro3carp3: 460
RtlZeroMemory - Microsoft: 405
ZeroMemD - unknown: 475
fZeroMemory- Four-F: 453
memfill - masm32 lib: 548
AzmtMemZero - jdoe 547
RtlFillMemory - Microsoft(NT+ only)412
msvcrt memset - Microsoft 354
Press any key to continue ...