I have a very curious result of running the demo.
-------------------- Host info --------------------
OS: Microsoft Windows NT 10.0.17763.0, x64
VBA7-x64
Host Product: Microsoft Office 2016 x64
Host Version: 16.0.4266.1001
Host Executable: EXCEL.EXE
VBA6-x32
Host Product: Microsoft Office XP x86
Host Version: 10.0.6501
Host Executable: EXCEL.EXE
Immediate output after running the demo routine.
| Operation | Method | Times | time, s / VBA6-x32 | time, s / VBA7-x64 |
|---|---|---|---|---|
| Copy <Byte> | By Ref | 106 | 0.383 | 0.414 |
| Copy <Byte> | By API | 106 | 0.023 | 2.062 |
| Copy <Integer> | By Ref | 106 | 0.352 | 0.375 |
| Copy <Integer> | By API | 106 | 0.031 | 2.047 |
| Copy <Long> | By Ref | 106 | 0.781 | 0.375 |
| Copy <Long> | By API | 106 | 0.062 | 2.047 |
| Copy <LongLong> | By Ref | 106 | 0.508 | 0.484 |
| Copy <LongLong> | By API | 106 | 0.031 | 2.055 |
| Dereferenced an Object | - | 106 | 0.156 | 0.188 |
There is a minor bug in the demo code. You have:
t = Timer
For i = 1 To LOOPS
CopyMemory x1, x2, 1
Next i
should be
Dim ByteCount As Long
ByteCount = Len(x1)
t = Timer
For i = 1 To LOOPS
CopyMemory x1, x2, ByteCount
Next i