mirror of
https://github.com/codex-storage/nim-codex.git
synced 2025-02-16 06:46:36 +00:00
add failing test case for memory leak
This commit is contained in:
parent
5d0c201882
commit
a3ae613fff
31
tests/codex/utils/asyncprofiler/testasyncprofiler.nim
Normal file
31
tests/codex/utils/asyncprofiler/testasyncprofiler.nim
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
import pkg/asynctest
|
||||||
|
import pkg/chronos
|
||||||
|
|
||||||
|
import pkg/codex/utils/asyncprofiler
|
||||||
|
|
||||||
|
type
|
||||||
|
FakeFuture = object
|
||||||
|
id: uint
|
||||||
|
internalLocation*: array[LocationKind, ptr SrcLoc]
|
||||||
|
|
||||||
|
|
||||||
|
suite "asyncprofiler":
|
||||||
|
|
||||||
|
test "should not keep metrics for a pending future in memory after it completes":
|
||||||
|
|
||||||
|
var fakeLoc = SrcLoc(procedure: "foo", file: "foo.nim", line: 1)
|
||||||
|
let future = FakeFuture(
|
||||||
|
id: 1,
|
||||||
|
internalLocation: [
|
||||||
|
LocationKind.Create: addr fakeLoc,
|
||||||
|
LocationKind.Finish: addr fakeLoc,
|
||||||
|
])
|
||||||
|
|
||||||
|
var profiler = AsyncProfiler[FakeFuture]()
|
||||||
|
|
||||||
|
profiler.handleFutureCreate(future)
|
||||||
|
profiler.handleFutureComplete(future)
|
||||||
|
|
||||||
|
check len(profiler.getPerFutureMetrics()) == 0
|
||||||
|
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user