#!/bin/sh -v /usr/local/bin/ruby -e ' def pi(n) (10**n).times.reduce(0) { |r, i| r + (-1.0)**i / (2 * i + 1) } end def time start = Time.now result = yield diff = Time.now - start puts "Elapsed time: #{diff} sec" p result end time { pi 8 } '