@program bench.muf 1 10000 d i $def PAYLOAD 1 pop : bench ( -- ips ) pid getpidinfo "instcnt" [] var! sinst systime_precise 0 begin systime_precise 3 pick - 3 < while PAYLOAD 10 + repeat pop systime_precise swap - pid getpidinfo "instcnt" [] sinst @ - swap / ; : rawbench ( estimateips -- insts secs ) 3 * pid getpidinfo "instcnt" [] var! sinst systime_precise 0 begin 3 pick over - 0 > while 10 + repeat pop pid getpidinfo "instcnt" [] sinst @ - (estinsts start realinsts) rot pop systime_precise rot - (insts secs) ; : primbench ( estimatedips -- ips ) dup var! estips 5 * pid getpidinfo "instcnt" [] var! sinst systime_precise 0 begin 3 pick over - 0 > while PAYLOAD 10 + repeat pop pid getpidinfo "instcnt" [] sinst @ - (estinsts start realinsts) rot pop systime_precise rot - (insts secs) estips @ rawbench (instspl secspl instraw secsraw) rot swap - (instspl instsraw deltasecs) rot rot - swap / ; : showresult[ ips benchname -- ips ] { pr_mode "preempt" fg_mode "foreground" bg_mode "background" }dict mode [] ips @ 1000.0 / benchname @ "%s: %8.1f K muf insts/sec, %s." fmtstring .tell descr descrflush ips @ ; : main pop "Beginning benchmarks." .tell preempt bench primbench "Payload Bench" showresult foreground bench primbench "Payload Bench" showresult background bench primbench "Payload Bench" showresult "Benchmarks complete." .tell pop ; . c q