There are native implementations for time and memory performance checks.
IIUF the only thing that is missing in the "stop when time ends".

I suggest using:
http://www.ruby-doc.org/stdlib-2.1.1/libdoc/timeout/rdoc/Timeout.html
together with:
http://www.ruby-doc.org/stdlib-2.1.1/libdoc/benchmark/rdoc/Benchmark.html

'''
require 'benchmark'
require 'timeout'
status = Timeout::timeout(5) {
  Benchmark.measure { "a"*1_000_000_000 }
}
'''