make some tests faster (#9413)
* remove duplicated slow test * smaller `convex hull` * smaller sleep * faster `trtree` * smaller sleep in `tfuturestream`
This commit is contained in:
parent
81e33b9d87
commit
95504caa31
5 changed files with 20 additions and 43 deletions
|
|
@ -19,7 +19,7 @@ var fs = newFutureStream[int]()
|
||||||
proc alpha() {.async.} =
|
proc alpha() {.async.} =
|
||||||
for i in 0 .. 5:
|
for i in 0 .. 5:
|
||||||
await fs.write(i)
|
await fs.write(i)
|
||||||
await sleepAsync(1000)
|
await sleepAsync(200)
|
||||||
|
|
||||||
echo("Done")
|
echo("Done")
|
||||||
fs.complete()
|
fs.complete()
|
||||||
|
|
|
||||||
|
|
@ -3,10 +3,9 @@ discard """
|
||||||
output: '''
|
output: '''
|
||||||
done
|
done
|
||||||
And we get here
|
And we get here
|
||||||
true
|
1
|
||||||
true
|
2
|
||||||
true
|
3
|
||||||
true
|
|
||||||
'''
|
'''
|
||||||
"""
|
"""
|
||||||
import hashes, sequtils, tables
|
import hashes, sequtils, tables
|
||||||
|
|
@ -119,8 +118,7 @@ block thashes:
|
||||||
newTable[uint32, string](),
|
newTable[uint32, string](),
|
||||||
newTable[uint64, string](),
|
newTable[uint64, string](),
|
||||||
)
|
)
|
||||||
|
echo "1"
|
||||||
echo "true"
|
|
||||||
|
|
||||||
|
|
||||||
block tindexby:
|
block tindexby:
|
||||||
|
|
@ -188,7 +186,7 @@ block ttables2:
|
||||||
|
|
||||||
|
|
||||||
run1()
|
run1()
|
||||||
echo "true"
|
echo "2"
|
||||||
|
|
||||||
|
|
||||||
block tablesref:
|
block tablesref:
|
||||||
|
|
@ -355,21 +353,4 @@ block tablesref:
|
||||||
assert t.len() == 0
|
assert t.len() == 0
|
||||||
|
|
||||||
orderedTableSortTest()
|
orderedTableSortTest()
|
||||||
echo "true"
|
echo "3"
|
||||||
|
|
||||||
|
|
||||||
block tablesref2:
|
|
||||||
proc TestHashIntInt() =
|
|
||||||
var tab = newTable[int,int]()
|
|
||||||
for i in 1..1_000_000:
|
|
||||||
tab[i] = i
|
|
||||||
for i in 1..1_000_000:
|
|
||||||
var x = tab[i]
|
|
||||||
if x != i : echo "not found ", i
|
|
||||||
|
|
||||||
proc run1() = # occupied Memory stays constant, but
|
|
||||||
for i in 1 .. 50: # aborts at run: 44 on win32 with 3.2GB with out of memory
|
|
||||||
TestHashIntInt()
|
|
||||||
|
|
||||||
run1()
|
|
||||||
echo "true"
|
|
||||||
|
|
|
||||||
|
|
@ -67,7 +67,7 @@ proc center(r: Box): auto =#BoxCenter[r.len, type(r[0].a)] =
|
||||||
for i in 0 .. r.high:
|
for i in 0 .. r.high:
|
||||||
when r[0].a is SomeInteger:
|
when r[0].a is SomeInteger:
|
||||||
result[i] = (r[i].a + r[i].b) div 2
|
result[i] = (r[i].a + r[i].b) div 2
|
||||||
elif r[0].a is SomeReal:
|
elif r[0].a is SomeFloat:
|
||||||
result[i] = (r[i].a + r[i].b) / 2
|
result[i] = (r[i].a + r[i].b) / 2
|
||||||
else: assert false
|
else: assert false
|
||||||
return result
|
return result
|
||||||
|
|
@ -81,7 +81,7 @@ proc distance(c1, c2: BoxCenter): auto =
|
||||||
proc overlap(r1, r2: Box): auto =
|
proc overlap(r1, r2: Box): auto =
|
||||||
result = type(r1[0].a)(1)
|
result = type(r1[0].a)(1)
|
||||||
for i in 0 .. r1.high:
|
for i in 0 .. r1.high:
|
||||||
result *= (min(r1[i]. b, r2[i]. b) - max(r1[i]. a, r2[i]. a))
|
result *= (min(r1[i]. b, r2[i]. b) - max(r1[i]. a, r2[i]. a))
|
||||||
if result <= 0: return 0
|
if result <= 0: return 0
|
||||||
|
|
||||||
proc union(r1, r2: Box): Box =
|
proc union(r1, r2: Box): Box =
|
||||||
|
|
@ -278,7 +278,7 @@ proc rstarSplit[M, D: Dim; RT, LT](t: RStarTree[M, D, RT, LT]; n: var Node[M, D,
|
||||||
for i in i0 .. n.a.high:
|
for i in i0 .. n.a.high:
|
||||||
result.a[i - i0] = nbest.a[i]
|
result.a[i - i0] = nbest.a[i]
|
||||||
n.numEntries = i0 + 1
|
n.numEntries = i0 + 1
|
||||||
result.numEntries = M - i0
|
result.numEntries = M - i0
|
||||||
when n is Node[M, D, RT, LT]:
|
when n is Node[M, D, RT, LT]:
|
||||||
for i in 0 ..< result.numEntries:
|
for i in 0 ..< result.numEntries:
|
||||||
result.a[i].n.parent = result
|
result.a[i].n.parent = result
|
||||||
|
|
@ -302,7 +302,7 @@ proc quadraticSplit[M, D: Dim; RT, LT](t: RTree[M, D, RT, LT]; n: var Node[M, D,
|
||||||
else:
|
else:
|
||||||
n1.a[0] = n.a[s1]
|
n1.a[0] = n.a[s1]
|
||||||
dec(n.numEntries)
|
dec(n.numEntries)
|
||||||
if s2 == n.numEntries: # important fix
|
if s2 == n.numEntries: # important fix
|
||||||
s2 = s1
|
s2 = s1
|
||||||
n.a[s1] = n.a[n.numEntries]
|
n.a[s1] = n.a[n.numEntries]
|
||||||
inc(n1.numEntries)
|
inc(n1.numEntries)
|
||||||
|
|
@ -651,7 +651,7 @@ when isMainModule:
|
||||||
assert r.len == r2.len
|
assert r.len == r2.len
|
||||||
assert r.sorted(system.cmp) == r2.sorted(system.cmp)
|
assert r.sorted(system.cmp) == r2.sorted(system.cmp)
|
||||||
|
|
||||||
test(5500)
|
test(1500)
|
||||||
|
|
||||||
# 651 lines
|
# 651 lines
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,6 @@
|
||||||
discard """
|
discard """
|
||||||
output: '''true
|
output: '''
|
||||||
true
|
'''
|
||||||
true
|
|
||||||
true
|
|
||||||
true
|
|
||||||
true'''
|
|
||||||
|
|
||||||
ccodeCheck: "\\i ! @'deepCopy(' .*"
|
ccodeCheck: "\\i ! @'deepCopy(' .*"
|
||||||
"""
|
"""
|
||||||
|
|
@ -55,10 +51,10 @@ proc convex_hull[T](points: var seq[T], cmp: proc(x, y: T): int {.closure.}) : s
|
||||||
ul[k] = spawn half[T](points, k == 0)
|
ul[k] = spawn half[T](points, k == 0)
|
||||||
result = concat(^ul[0], ^ul[1])
|
result = concat(^ul[0], ^ul[1])
|
||||||
|
|
||||||
var s = map(toSeq(0..999999), proc(x: int): Point = (float(x div 1000), float(x mod 1000)))
|
var s = map(toSeq(0..99999), proc(x: int): Point = (float(x div 1000), float(x mod 1000)))
|
||||||
setMaxPoolSize 2
|
setMaxPoolSize 2
|
||||||
|
|
||||||
#echo convex_hull[Point](s, cmpPoint)
|
#echo convex_hull[Point](s, cmpPoint)
|
||||||
for i in 0..5:
|
for i in 0..5:
|
||||||
echo convex_hull[Point](s, cmpPoint) ==
|
doAssert convex_hull[Point](s, cmpPoint) ==
|
||||||
@[(0.0, 0.0), (999.0, 0.0), (999.0, 999.0), (0.0, 999.0)]
|
@[(0.0, 0.0), (99.0, 0.0), (99.0, 999.0), (0.0, 999.0)]
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ proc timer(d: int): int =
|
||||||
#echo fmt"done {d}"
|
#echo fmt"done {d}"
|
||||||
return d
|
return d
|
||||||
|
|
||||||
var durations = [1000, 2000, 3000, 4000, 5000]
|
var durations = [1000, 1500, 2000, 2500, 3000]
|
||||||
var tasks: seq[FlowVarBase] = @[]
|
var tasks: seq[FlowVarBase] = @[]
|
||||||
var results: seq[int] = @[]
|
var results: seq[int] = @[]
|
||||||
|
|
||||||
|
|
@ -27,9 +27,9 @@ while index != -1:
|
||||||
|
|
||||||
doAssert results.len == 5
|
doAssert results.len == 5
|
||||||
doAssert 1000 in results
|
doAssert 1000 in results
|
||||||
|
doAssert 1500 in results
|
||||||
doAssert 2000 in results
|
doAssert 2000 in results
|
||||||
|
doAssert 2500 in results
|
||||||
doAssert 3000 in results
|
doAssert 3000 in results
|
||||||
doAssert 4000 in results
|
|
||||||
doAssert 5000 in results
|
|
||||||
sync()
|
sync()
|
||||||
echo "true"
|
echo "true"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue