Sha256: 77120c3059a192cda18eb099f73fad37610c5ef5be15f6be3cb903aa3a7e5bf5
Contents?: true
Size: 621 Bytes
Versions: 1
Compression:
Stored size: 621 Bytes
Contents
#input: instance_name benches n reps of method_name (with *args) #example: graph benches 50000 reps of dfs def routine(instance, input) params = input.split(" ") if params.last == params[4] args = nil else args = coerce_args(input[/\(.*?\)/].gsub(/[()]/, "").split(",")) end Benches::Routine.new(instance, params[4], params[1].to_i, *args).call end def coerce_args(args) args.map do |arg| if integer?(arg) arg.to_i elsif float?(arg) arg.to_f else arg end end end def integer?(input) !!(/^\d+$/ =~ input) end def float?(input) !!(/^\d+(.\d+)$/ =~ input) end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
benches-0.1.0 | lib/benches/dsl.rb |