require 'compsci/timer' include CompSci overall_start = Timer.now start = Timer.now print "running sleep 0.01 (50x): " _answer, each_et = Timer.loop_average(count: 50) { print '.' sleep 0.01 } puts puts "each: %0.3f" % each_et puts "elapsed: %0.3f" % Timer.since(start) puts "cumulative: %0.3f" % Timer.since(overall_start) puts start = Timer.now print "running sleep 0.02 (0.5 s): " _answer, each_et = Timer.loop_average(seconds: 0.5) { print '.' sleep 0.02 } puts puts "each: %0.3f" % each_et puts "elapsed: %0.3f" % Timer.since(start) puts "cumulative: %0.3f" % Timer.since(overall_start) puts start = Timer.now print "running sleep 2 (1 s): " _answer, each_et = Timer.loop_average(seconds: 1) { print '.' sleep 2 } puts puts "each: %0.3f" % each_et puts "elapsed: %0.3f" % Timer.since(start) puts "cumulative: %0.3f" % Timer.since(overall_start)