Code: Select all
;Test with short strings
;a$="x"
;b$="x"
;Test with longer strings
a$="jjkgkdjghklsdghsdklfghkldghlgögjäfjeögheögtegdfkvbjsdgkljsdfhgkdhgösdfhgklsdghskdlghksldfghskldfghsdklfghskldfghklsdghsdklfghskldfghsdklfghsdklghklsdfghksldfghksdghksdfghskdghklsdg"
b$="jjkgkdjghklsdghsdklfghkldghlgögjäfjeögheögtegdfkvbjsdgkljsdfhgkdhgösdfhgklsdghskdlghksldfghskldfghsdklfghskldfghklsdghsdklfghskldfghsdklfghsdklghklsdfghksldfghksdghksdfghskdghklsdg"
time1 = ElapsedMilliseconds()
For i = 1 To 10000000
If a$ = b$
x1 + 1
EndIf
Next
time1 = ElapsedMilliseconds() - time1
time2 = ElapsedMilliseconds()
For i = 1 To 10000000
If PeekI (@a$) = PeekI (@b$)
x2 + 1
EndIf
Next
time2 = ElapsedMilliseconds() - time2
MessageRequester ("", "" + x1 + " - " + time1 + #CRLF$ + x2 + " - " + time2)
I am not 100% sure if a negative comparison is valid in every case. A positive comparison is valid in any case and the time reduction would even be worth to make a precheck for a positiv result.