Commit 9609a451 authored by Benjamin Summerton's avatar Benjamin Summerton

Cleanup extra whitespace in tester code

parent ff00839a
...@@ -3,7 +3,7 @@ from sequtils import map ...@@ -3,7 +3,7 @@ from sequtils import map
# Choose where to get the "sleep" function from # Choose where to get the "sleep" function from
when defined(js): when defined(js):
# NOTE: This isn't giving me the result I want... # NOTE: This isn't giving me the result I want...
proc sleep(ms: int) = proc sleep(ms: int) =
{.emit: ["return new Promise(resolve => setTimeout(resolve,", ms, "));"].} {.emit: ["return new Promise(resolve => setTimeout(resolve,", ms, "));"].}
...@@ -24,26 +24,26 @@ var ...@@ -24,26 +24,26 @@ var
proc test() = proc test() =
# Print a message # Print a message
echo "Testing with laps ", (if recordLaps: "on." else: "off.") echo "Testing with laps ", (if recordLaps: "on." else: "off.")
# Init the stopwatch and go # Init the stopwatch and go
sw = stopwatch(recordLaps) sw = stopwatch(recordLaps)
echo "laps=", sw.laps(true) echo "laps=", sw.laps(true)
echo "total=", sw.totalSecs echo "total=", sw.totalSecs
sw.start() sw.start()
echo "laps=", sw.laps(true) echo "laps=", sw.laps(true)
sleep(1000) sleep(1000)
echo "total=", sw.totalSecs echo "total=", sw.totalSecs
sw.stop() sw.stop()
echo sw.secs echo sw.secs
#echo sw.msecs #echo sw.msecs
#echo sw.usecs #echo sw.usecs
#echo sw.nsecs #echo sw.nsecs
echo "total=", sw.totalSecs echo "total=", sw.totalSecs
echo "" echo ""
sw.start() sw.start()
sleep(500) sleep(500)
echo "total=", sw.totalSecs echo "total=", sw.totalSecs
...@@ -52,7 +52,7 @@ proc test() = ...@@ -52,7 +52,7 @@ proc test() =
echo sw.secs echo sw.secs
echo "total=", sw.totalSecs echo "total=", sw.totalSecs
echo "" echo ""
sw.start() sw.start()
echo sw.secs echo sw.secs
sleep(100) sleep(100)
...@@ -69,9 +69,9 @@ proc test() = ...@@ -69,9 +69,9 @@ proc test() =
echo sw.secs echo sw.secs
echo "total=", sw.totalSecs echo "total=", sw.totalSecs
echo "" echo ""
var sw2 = sw.clone() var sw2 = sw.clone()
echo "lapCount=", sw.numLaps echo "lapCount=", sw.numLaps
echo "L1=", sw.lap(0).secs echo "L1=", sw.lap(0).secs
echo "L2=", if sw.isRecordingLaps: sw.laps()[1].secs else: 0 echo "L2=", if sw.isRecordingLaps: sw.laps()[1].secs else: 0
...@@ -80,12 +80,12 @@ proc test() = ...@@ -80,12 +80,12 @@ proc test() =
echo "lapCount=", sw.numLaps echo "lapCount=", sw.numLaps
echo "----" echo "----"
echo "lapCount=", sw2.numLaps echo "lapCount=", sw2.numLaps
var lapsSecs = sw2.laps().map(proc(x: int64): float = secs(x)) var lapsSecs = sw2.laps().map(proc(x: int64): float = secs(x))
echo "all laps(s)=", lapsSecs echo "all laps(s)=", lapsSecs
echo "" echo ""
sw.reset() sw.reset()
echo "lapCount=", sw.numLaps echo "lapCount=", sw.numLaps
sw.start() sw.start()
...@@ -99,10 +99,10 @@ proc test() = ...@@ -99,10 +99,10 @@ proc test() =
echo "total(u)=", sw.totalUsecs echo "total(u)=", sw.totalUsecs
echo "total(n)=", sw.totalNsecs echo "total(n)=", sw.totalNsecs
echo "" echo ""
bench(sw, sleep(1000)) bench(sw, sleep(1000))
echo "bench(sleep(1000))=", sw.secs echo "bench(sleep(1000))=", sw.secs
# Test with laps or no laps via an argument (non-js only) # Test with laps or no laps via an argument (non-js only)
...@@ -119,5 +119,3 @@ else: ...@@ -119,5 +119,3 @@ else:
recordLaps = false recordLaps = false
test() test()
...@@ -23,23 +23,23 @@ proc test() = ...@@ -23,23 +23,23 @@ proc test() =
# Print a message # Print a message
echo "Testing with laps ", (if recordLaps: "on." else: "off.") echo "Testing with laps ", (if recordLaps: "on." else: "off.")
# Init the stopwatch and go # Init the stopwatch and go
sw = stopwatch(recordLaps) sw = stopwatch(recordLaps)
echo "laps=", sw.laps(true) echo "laps=", sw.laps(true)
echo "total=", sw.totalSecs echo "total=", sw.totalSecs
sw.start() sw.start()
echo "laps=", sw.laps(true) echo "laps=", sw.laps(true)
sleep(1000) sleep(1000)
echo "total=", sw.totalSecs echo "total=", sw.totalSecs
sw.stop() sw.stop()
echo sw.secs echo sw.secs
echo "total=", sw.totalSecs echo "total=", sw.totalSecs
echo "" echo ""
sw.start() sw.start()
sleep(500) sleep(500)
echo "total=", sw.totalSecs echo "total=", sw.totalSecs
...@@ -48,7 +48,7 @@ proc test() = ...@@ -48,7 +48,7 @@ proc test() =
echo sw.secs echo sw.secs
echo "total=", sw.totalSecs echo "total=", sw.totalSecs
echo "" echo ""
sw.start() sw.start()
echo sw.secs echo sw.secs
sleep(100) sleep(100)
...@@ -63,9 +63,9 @@ proc test() = ...@@ -63,9 +63,9 @@ proc test() =
echo sw.secs echo sw.secs
echo "total=", sw.totalSecs echo "total=", sw.totalSecs
echo "" echo ""
var sw2 = sw.clone() var sw2 = sw.clone()
echo "lapCount=", sw.numLaps echo "lapCount=", sw.numLaps
echo "L1=", sw.lap(0).secs echo "L1=", sw.lap(0).secs
echo "L2=", if sw.isRecordingLaps: sw.laps()[1].secs else: 0 echo "L2=", if sw.isRecordingLaps: sw.laps()[1].secs else: 0
...@@ -74,12 +74,12 @@ proc test() = ...@@ -74,12 +74,12 @@ proc test() =
echo "lapCount=", sw.numLaps echo "lapCount=", sw.numLaps
echo "----" echo "----"
echo "lapCount=", sw2.numLaps echo "lapCount=", sw2.numLaps
var lapsSecs = sw2.laps().map(proc(x: int): float = secs(x)) var lapsSecs = sw2.laps().map(proc(x: int): float = secs(x))
echo "all laps(s)=", lapsSecs echo "all laps(s)=", lapsSecs
echo "" echo ""
sw.reset() sw.reset()
echo "lapCount=", sw.numLaps echo "lapCount=", sw.numLaps
sw.start() sw.start()
...@@ -91,10 +91,10 @@ proc test() = ...@@ -91,10 +91,10 @@ proc test() =
echo "total(s)=", sw.totalSecs echo "total(s)=", sw.totalSecs
echo "total(m)=", sw.totalMsecs echo "total(m)=", sw.totalMsecs
echo "" echo ""
bench(sw, sleep(1000)) bench(sw, sleep(1000))
echo "bench(sleep(1000))=", sw.secs echo "bench(sleep(1000))=", sw.secs
# Call test inside body.onload for browser JS # Call test inside body.onload for browser JS
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment