summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/testr/testr.myr20
-rw-r--r--mbld/opts.myr2
-rw-r--r--support/dumpleak.myr2
3 files changed, 17 insertions, 7 deletions
diff --git a/lib/testr/testr.myr b/lib/testr/testr.myr
index 06fcfce..959451e 100644
--- a/lib/testr/testr.myr
+++ b/lib/testr/testr.myr
@@ -21,8 +21,6 @@ pkg testr =
const softfail : (ctx : ctx#, msg : byte[:], args : ... -> void)
;;
-const Nsamp = 1000;
-
const bench = {specs
std.put("MTEST {}\n", specs.len)
for s : specs
@@ -78,7 +76,7 @@ const softfailv = {ctx, msg, ap
}
const benchspec = {ts
- var avg, m, d, n
+ var avg, m, d, n, nsamp
var start, dt
var ctx : ctx
var jmpbuf
@@ -90,9 +88,21 @@ const benchspec = {ts
avg = 0.0;
m = 0.0;
n = 0.0;
+ nsamp = 0
std.put("test {} <<{{!\n", ts.name)
if !std.setjmp(&jmpbuf)
- for var i = 0; i < Nsamp; i++
+ /* estimate samples */
+ start = std.now()
+ ts.fn(&ctx)
+ dt = (std.now() - start : flt64)
+
+ if dt == 0.0
+ nsamp = 1000_000
+ else
+ nsamp = (1000_000.0/dt : std.time)
+ ;;
+
+ for var i = 0; i < nsamp; i++
n +=1.0;
start = std.now()
ts.fn(&ctx)
@@ -104,7 +114,7 @@ const benchspec = {ts
;;
if ctx.ok
- std.put("!}}>> timing {} {} {}\n", Nsamp, avg, m)
+ std.put("!}}>> timing {} {} {}\n", nsamp, avg, m)
else
std.put("!}}>> fail {}\n", ctx.reason)
std.slfree(ctx.reason)
diff --git a/mbld/opts.myr b/mbld/opts.myr
index ca11d56..7f73350 100644
--- a/mbld/opts.myr
+++ b/mbld/opts.myr
@@ -89,7 +89,7 @@ const parseversion = {v
i = 0
a = [0, 0, 0]
- for e in std.bysplit(v, ".")
+ for e : std.bysplit(v, ".")
match std.intparse(e)
| `std.Some n: a[i++] = n
| `std.None: continue
diff --git a/support/dumpleak.myr b/support/dumpleak.myr
index 350298a..557e8aa 100644
--- a/support/dumpleak.myr
+++ b/support/dumpleak.myr
@@ -78,7 +78,7 @@ const tracealloc = {path, f, stats
ptr = get64(path, f)
sz = get64(path, f)
stk = [][:]
- for var i = 0; i < 10; i++
+ for var i = 0; i < 20; i++
std.slpush(&stk, get64(path, f))
;;
stats.allocs++