**** generating 10000 random numbers & writing them to a buffer ****
Intel(R) Core(TM) i5-2450M CPU @ 2.50GHz (SSE4)
++-++++++11 of 20 tests valid,
11906 kCycles for 10 * random Str$() MasmBasic
18391 kCycles for 10 * random dwtoa Masm32 SDK
16720 kCycles for 10 * random Str$() MasmBasic with saving
23448 kCycles for 10 * random dwtoa Masm32 SDK with saving
139015 kCycles for 10 * random sprintf CRT
156212 kCycles for 10 * random sprintf CRT with saving
11292 kCycles for 10 * random Str$() MasmBasic
18338 kCycles for 10 * random dwtoa Masm32 SDK
16328 kCycles for 10 * random Str$() MasmBasic with saving
29636 kCycles for 10 * random dwtoa Masm32 SDK with saving
139799 kCycles for 10 * random sprintf CRT
145937 kCycles for 10 * random sprintf CRT with saving
13457 kCycles for 10 * random Str$() MasmBasic
24111 kCycles for 10 * random dwtoa Masm32 SDK
17040 kCycles for 10 * random Str$() MasmBasic with saving
23754 kCycles for 10 * random dwtoa Masm32 SDK with saving
139204 kCycles for 10 * random sprintf CRT
121430 kCycles for 10 * random sprintf CRT with saving
101 bytes for random Str$() MasmBasic
113 bytes for random dwtoa Masm32 SDK
89 bytes for random Str$() MasmBasic with saving
90 bytes for random dwtoa Masm32 SDK with saving
121 bytes for random sprintf CRT
89 bytes for random sprintf CRT with saving
edi points to a buffer and gets filled with strings of the format n<tab>random number<CrLf>:
0 220383915
1 771014011
2 2113869234
3 901510269
4 1077232086
5 1507169316
etc
MakeStringsMB proc uses edi
xor ecx, ecx
.Repeat
Str$(ecx, dest:edi) ; write #number to edi
mov edi, edx ; edx points to the end of the string
mov al, 9
stosb
Str$(Rand(7fffffffh), dest:edi) ; write #random to edi
mov edi, edx
mov ax, 0A0Dh
stosw
inc ecx
.Until ecx>numstrings
xor eax, eax
stosb
ret
MakeStringsMB endp
MakeStringsM32 proc uses edi ebx
xor ebx, ebx
.Repeat
invoke dwtoa, ebx, edi ; pretty fast Masm32 library algo
add edi, len(edi) ; dwtoa doesn't tell us how many bytes were copied...
mov al, 9
stosb
invoke dwtoa, Rand(7fffffffh), edi ; use MasmBasic Rand() to make sure the choice of PRNG does not influence timings
add edi, len(edi)
mov ax, 0A0Dh
stosw
inc ebx
.Until ebx>numstrings
xor eax, eax
stosb
ret
MakeStringsM32 endp
MakeStringsCRT proc uses edi ebx
xor ebx, ebx
.Repeat
invoke crt_sprintf, edi, chr$("%i", 9), ebx ; slow CRT
add edi, rv(lstrlen, edi) ; sprintf doesn't tell us how many bytes were copied...
invoke crt_sprintf, edi, chr$("%i", 13, 10), Rand(7fffffffh)
add edi, rv(lstrlen, edi)
inc ebx
.Until ebx>numstrings
xor eax, eax
stosb
ret
MakeStringsCRT endp