module BenchmarkDriver

def build_contexts_with_executables(contexts, executables)

def build_contexts_with_executables(contexts, executables)
  # Create direct product of contexts
  contexts.product(executables).map do |context, executable|
    name = context.name
    if name.nil?
      # Use the first gem name and version by default
      name = context.gems.first.join(' ')
      # Append Ruby executable name if it's matrix
      if executables.size > 1
        name = "#{name} (#{executable.name})"
      end
    end
    BenchmarkDriver::Context.new(
      name: name,
      executable: executable,
      gems: context.gems,
      prelude: context.prelude,
    )
  end
end