Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
timotheecour committed Jan 9, 2019
1 parent 0229dfd commit 29a2e49
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions lib/pure/nimprof.nim
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,15 @@ type
st: StackTrace
ProfileData = array[0..64*1024-1, ptr ProfileEntry]

proc `==`(x, y: cstring): bool {.noSideEffect, inline.} =
## Checks for equality between two `cstring` variables.
# copied over from system.nim as workaround for #10106
proc strcmp(a, b: cstring): cint {.noSideEffect,
importc, header: "<string.h>".}
if pointer(x) == pointer(y): result = true
elif x.isNil or y.isNil: result = false
else: result = strcmp(x, y) == 0

proc `==`(a, b: StackTrace): bool =
for i in 0 .. high(a.lines):
if a[i] != b[i]: return false
Expand Down Expand Up @@ -146,7 +155,7 @@ else:
dec gTicker

proc hook(st: StackTrace) {.nimcall, locks: 0.} =
#echo "profiling! ", interval
# echo "profiling! ", interval
if interval == 0:
hookAux(st, 1)
else:
Expand All @@ -167,7 +176,7 @@ proc writeProfile() {.noconv.} =
when declared(system.StackTrace):
system.profilerHook = nil
const filename = "profile_results.txt"
echo "writing " & filename & "..."
echo "writing " & filename & " ..."
var f: File
if open(f, filename, fmWrite):
sort(profileData, cmpEntries)
Expand Down

0 comments on commit 29a2e49

Please sign in to comment.