Skip to content

Instantly share code, notes, and snippets.

@qtxie
Last active September 13, 2019 07:45
Show Gist options
  • Save qtxie/5cd424581905ad214dff5b8889478707 to your computer and use it in GitHub Desktop.
Save qtxie/5cd424581905ad214dff5b8889478707 to your computer and use it in GitHub Desktop.
Red/System []
int64!: alias struct! [
low [integer!]
high [integer!]
]
sub64: func [
a [int64!]
b [int64!]
return: [integer!]
][
;-- mov edx, [ebp + 8]
;-- mov ecx, [ebp + 12]
;-- mov eax, [edx]
;-- mov edx, [edx + 4]
;-- sub eax, [ecx]
;-- sbb edx, [ecx + 4]
#inline [
#{8B55088B4D0C8B028B52042B011B5104}
return: [integer!]
]
]
rdtsc: func [n [int64!]][
;-- rdtsc
;-- cdq
;-- mov ecx, DWORD PTR [ebp+8]
;-- mov DWORD PTR [ecx], eax
;-- mov DWORD PTR [ecx+4], edx
#inline #{0F31998B4D088901895104}
]
test: func [
/local
f [float!]
n [integer!]
t1 [int64! value]
t2 [int64! value]
][
rdtsc :t1
n: 0
loop 10000000 [n: n + 1]
rdtsc :t2
probe [sub64 :t2 :t1]
rdtsc :t1
f: 0.0
loop 10000000 [f: f + 1.0]
rdtsc :t2
probe [sub64 :t2 :t1]
]
test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment