When I test the rep movsb method, I get a slower result than with CopyMemory.
CopyMemory: 328ms
rep movsb method: 877ms
That's with PB 5.21 LTS x86 with debugger off.
memcpy results in slightly faster code in my tests; ranging from 244ms to 294ms
Code:
Structure decoder_table
index.l
Array cs.a(200)
EndStructure
Structure colorbits
index.l
byte.a[0]
EndStructure
Dim codestrings.decoder_table(0)
codestrings(0)\index = 150
*outstream.colorbits = AllocateMemory(1024)
*outstream\index = 100
; Move 150 bytes from codestrings array to outstream starting at *outstream\index
#test_size = 9999999
s1 = ElapsedMilliseconds()
For i = 1 To #test_size
CopyMemory(codestrings(0)\cs(), @*outstream\byte[0]+*outstream\index, codestrings(0)\index)
Next
e1 = ElapsedMilliseconds()
Procedure CopyPattern(*source, *dest, size)
!cld
!mov esi, [esp+4]
!mov edi, [esp+8]
!mov ecx, [esp+12]
!rep movsb
EndProcedure
ImportC "" : memcpy.i (*dest, *src, sz) : EndImport
s2 = ElapsedMilliseconds()
For i = 1 To #test_size
;CopyPattern(codestrings(0)\cs(), @*outstream\byte[0]+*outstream\index, codestrings(0)\index)
memcpy(@*outstream\byte[0]+*outstream\index, codestrings(0)\cs(), codestrings(0)\index)
Next
e2 = ElapsedMilliseconds()
OpenConsole()
PrintN("time1: " + Str(e1 - s1) + "ms")
PrintN("time2: " + Str(e2 - s2) + "ms")
ImportC ""
system.i (command.s)
EndImport
system("pause")