Sha256: 0d6aaa316a9fc3ea56a92742720ae208eb52c6b5384704763afec346833478d7
Contents?: true
Size: 1.89 KB
Versions: 3
Compression:
Stored size: 1.89 KB
Contents
require 'nudge' require '../lib/answer-factory' include Nudge include NudgeGP d1 = Answer.new("") d2 = Answer.new("") t1 = Time.now 100000.times do d1.scores = {"a" => rand(20)-10, "b" => rand(20)-10,"c" => rand(20)-10,"d" => rand(20)-10,"e" => rand(20)-10,"e1" => rand(20)-10,"e2" => rand(20)-10,"e3" => rand(20)-10,"e4" => rand(20)-10,"e5" => rand(20)-10,"e6" => rand(20)-10,"edfsgdf" => rand(20)-10,"se" => rand(20)-10} d2.scores = {"a" => rand(20)-10, "b" => rand(20)-10,"c" => rand(20)-10,"d" => rand(20)-10,"e" => rand(20)-10,"e1" => rand(20)-10,"e2" => rand(20)-10,"e3" => rand(20)-10,"e4" => rand(20)-10,"e5" => rand(20)-10,"e6" => rand(20)-10,"edfsgdf" => rand(20)-10,"se" => rand(20)-10} d1.dominated_by?(d2) end puts "#{Time.now - t1} sec from the new one" class Answer def dominated_by?(other, template = self.known_criteria) return false unless (known_criteria == other.known_criteria) noWorse = true somewhatBetter = false template.each do |score| if self.scores[score] && other.scores[score] noWorse &&= (self.scores[score] >= other.scores[score]) somewhatBetter ||= (self.scores[score] > other.scores[score]) else return false end end return noWorse && somewhatBetter end end t1 = Time.now 100000.times do d1.scores = {"a" => rand(20)-10, "b" => rand(20)-10,"c" => rand(20)-10,"d" => rand(20)-10,"e" => rand(20)-10,"e1" => rand(20)-10,"e2" => rand(20)-10,"e3" => rand(20)-10,"e4" => rand(20)-10,"e5" => rand(20)-10,"e6" => rand(20)-10,"edfsgdf" => rand(20)-10,"se" => rand(20)-10} d2.scores = {"a" => rand(20)-10, "b" => rand(20)-10,"c" => rand(20)-10,"d" => rand(20)-10,"e" => rand(20)-10,"e1" => rand(20)-10,"e2" => rand(20)-10,"e3" => rand(20)-10,"e4" => rand(20)-10,"e5" => rand(20)-10,"e6" => rand(20)-10,"edfsgdf" => rand(20)-10,"se" => rand(20)-10} d1.dominated_by?(d2) end puts "#{Time.now - t1} sec from the old one"
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
answer-factory-0.0.3 | _spikes/old_vs_new_dominated_by?.rb |
answer-factory-0.0.2 | _spikes/old_vs_new_dominated_by?.rb |
answer-factory-0.0.1 | _spikes/old_vs_new_dominated_by?.rb |