1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
|
# frozen_string_literal: true
require_relative '../base'
module Mongo
module DriverBench
module SingleDoc
# Abstract base class for all single-doc benchmarks.
#
# @api private
class Base < Mongo::DriverBench::Base
private
attr_reader :client, :collection
def setup
if file_name
@dataset ||= load_file(file_name).first
@dataset_size ||= size_of_file(file_name) * scale
end
prepare_client
end
# The amount by which the dataset size should be scaled (for scoring
# purposes).
def scale
10_000
end
def teardown
cleanup_client
end
def prepare_client
@client = new_client.use('perftest')
@client.database.drop
@collection = @client.database[:corpus].tap(&:create)
end
def cleanup_client
@client.database.drop
end
# Returns the name of the file that contains
# the dataset to use.
def file_name
nil
end
end
end
end
end
|