File: encodable.rb

package info (click to toggle)
ruby-mongo 2.23.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 15,020 kB
  • sloc: ruby: 110,810; makefile: 5
file content (29 lines) | stat: -rw-r--r-- 588 bytes parent folder | download
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
# frozen_string_literal: true

require_relative '../base'

module Mongo
  module DriverBench
    module BSON
      # Common behavior for the "encode" benchmarks.
      #
      # @api private
      module Encodable
        private

        # The document to encode for the test
        attr_reader :document

        # Before each task.
        def before_task
          @document = ::BSON::Document.new(dataset)
        end

        # The encode operation itself, executed 10k times.
        def do_task
          10_000.times { document.to_bson }
        end
      end
    end
  end
end