From 619d3e9d56e355bf1fb2af46520724f86fa32904 Mon Sep 17 00:00:00 2001 From: Jaremy Creechley Date: Wed, 30 Aug 2023 18:24:12 -0700 Subject: [PATCH] add tests for new ds'es --- tests/exampletaskpool.nim | 34 ---------------------------------- tests/testall.nim | 4 +++- 2 files changed, 3 insertions(+), 35 deletions(-) delete mode 100644 tests/exampletaskpool.nim diff --git a/tests/exampletaskpool.nim b/tests/exampletaskpool.nim deleted file mode 100644 index c410235..0000000 --- a/tests/exampletaskpool.nim +++ /dev/null @@ -1,34 +0,0 @@ - - -import - std/[strutils, math, cpuinfo], - taskpools - -# From https://github.com/nim-lang/Nim/blob/v1.6.2/tests/parallel/tpi.nim -# Leibniz Formula https://en.wikipedia.org/wiki/Leibniz_formula_for_%CF%80 -proc term(k: int): float = - if k mod 2 == 1: - -4'f / float(2*k + 1) - else: - 4'f / float(2*k + 1) - -proc piApprox(tp: Taskpool, n: int): float = - var pendingFuts = newSeq[FlowVar[float]](n) - for k in 0 ..< pendingFuts.len: - pendingFuts[k] = tp.spawn term(k) # Schedule a task on the threadpool a return a handle to retrieve the result. - for k in 0 ..< pendingFuts.len: - result += sync pendingFuts[k] # Block until the result is available. - -proc main() = - var n = 1_000_000 - var nthreads = countProcessors() - - var tp = Taskpool.new(num_threads = nthreads) # Default to the number of hardware threads. - - echo formatFloat(tp.piApprox(n)) - - tp.syncAll() # Block until all pending tasks are processed (implied in tp.shutdown()) - tp.shutdown() - -# Compile with nim c -r -d:release --threads:on --outdir:build example.nim -main() \ No newline at end of file diff --git a/tests/testall.nim b/tests/testall.nim index a6aca01..b491144 100644 --- a/tests/testall.nim +++ b/tests/testall.nim @@ -4,6 +4,8 @@ import ./datastore/testfsds, ./datastore/testsql, ./datastore/testtieredds, - ./datastore/testmountedds + ./datastore/testmountedds, + ./datastore/testmemoryds, + ./datastore/testthreadproxyds {.warning[UnusedImport]: off.}