Created
May 15, 2024 18:18
-
-
Save felixyz/7151d6acc1ef3d0d674caeacc9538862 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "bmg" | |
require "benchmark" | |
a_domain = (0..10_000).to_a | |
b_domain = %w[a b c d e f g h i j k l m n o p q] | |
puts "Generate relations..." | |
rels = (0..1_000).map do |n| | |
n_tuples = n == 0 ? 100_000 : 100 | |
Bmg::Relation.new((1..n_tuples).map do | |
{ a: a_domain.sample, b: b_domain.sample } | |
end) | |
end | |
puts "Generate derived relation" | |
minus = rels.drop(1).inject(rels[0]) do |agg, r| | |
agg.minus(r) | |
end | |
puts "Perform operations" | |
result = nil | |
puts Benchmark.measure { result = minus.to_a } | |
puts "Tuples left: #{result.count}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment