|
1 | 1 | # frozen_string_literal: true
|
2 |
| -# rubocop:todo all |
3 | 2 |
|
4 | 3 | # Copyright (C) 2015-2020 MongoDB Inc.
|
5 | 4 | #
|
|
23 | 22 | require_relative 'benchmarking/parallel'
|
24 | 23 |
|
25 | 24 | module Mongo
|
26 |
| - |
27 | 25 | # Module with all functionality for running driver benchmark tests.
|
28 | 26 | #
|
29 | 27 | # @since 2.2.3
|
30 | 28 | module Benchmarking
|
31 |
| - |
32 | 29 | extend self
|
33 | 30 |
|
34 |
| - # The current path. |
35 |
| - # |
36 |
| - # @return [ String ] The current path. |
37 |
| - # |
38 |
| - # @since 2.2.3 |
39 |
| - CURRENT_PATH = File.expand_path(File.dirname(__FILE__)).freeze |
40 |
| - |
41 |
| - # The path to data files used in Benchmarking tests. |
42 |
| - # |
43 | 31 | # @return [ String ] Path to Benchmarking test files.
|
44 |
| - # |
45 |
| - # @since 2.2.3 |
46 |
| - DATA_PATH = [CURRENT_PATH, 'benchmarking', 'data'].join('/').freeze |
| 32 | + DATA_PATH = [ __dir__, 'benchmarking', 'data' ].join('/').freeze |
47 | 33 |
|
48 |
| - # The file containing the single tweet document. |
49 |
| - # |
50 |
| - # @return [ String ] The file containing the tweet document. |
51 |
| - # |
52 |
| - # @since 2.2.3 |
53 |
| - TWEET_DOCUMENT_FILE = [DATA_PATH, 'TWEET.json'].join('/').freeze |
| 34 | + # @return [ String ] The file containing the single tweet document. |
| 35 | + TWEET_DOCUMENT_FILE = [ DATA_PATH, 'TWEET.json' ].join('/').freeze |
54 | 36 |
|
55 |
| - # The file containing the single small document. |
56 |
| - # |
57 |
| - # @return [ String ] The file containing the small document. |
58 |
| - # |
59 |
| - # @since 2.2.3 |
60 |
| - SMALL_DOCUMENT_FILE = [DATA_PATH, 'SMALL_DOC.json'].join('/').freeze |
| 37 | + # @return [ String ] The file containing the single small document. |
| 38 | + SMALL_DOCUMENT_FILE = [ DATA_PATH, 'SMALL_DOC.json' ].join('/').freeze |
61 | 39 |
|
62 |
| - # The file containing the single large document. |
63 |
| - # |
64 |
| - # @return [ String ] The file containing the large document. |
65 |
| - # |
66 |
| - # @since 2.2.3 |
67 |
| - LARGE_DOCUMENT_FILE = [DATA_PATH, 'LARGE_DOC.json'].join('/').freeze |
| 40 | + # @return [ String ] The file containing the single large document. |
| 41 | + LARGE_DOCUMENT_FILE = [ DATA_PATH, 'LARGE_DOC.json' ].join('/').freeze |
68 | 42 |
|
69 |
| - # The file to upload when testing GridFS. |
70 |
| - # |
71 |
| - # @return [ String ] The file containing the GridFS test data. |
72 |
| - # |
73 |
| - # @since 2.2.3 |
74 |
| - GRIDFS_FILE = [DATA_PATH, 'GRIDFS_LARGE'].join('/').freeze |
| 43 | + # @return [ String ] The file to upload when testing GridFS. |
| 44 | + GRIDFS_FILE = [ DATA_PATH, 'GRIDFS_LARGE' ].join('/').freeze |
75 | 45 |
|
76 |
| - # The file path and base name for the LDJSON files. |
77 |
| - # |
78 | 46 | # @return [ String ] The file path and base name for the LDJSON files.
|
79 |
| - # |
80 |
| - # @since 2.2.3 |
81 |
| - LDJSON_FILE_BASE = [DATA_PATH, 'LDJSON_MULTI', 'LDJSON'].join('/').freeze |
| 47 | + LDJSON_FILE_BASE = [ DATA_PATH, 'LDJSON_MULTI', 'LDJSON' ].join('/').freeze |
82 | 48 |
|
83 |
| - # The file path and base name for the outputted LDJSON files. |
84 |
| - # |
85 |
| - # @return [ String ] The file path and base name for the outputted LDJSON files. |
86 |
| - # |
87 |
| - # @since 2.2.3 |
88 |
| - LDJSON_FILE_OUTPUT_BASE = [DATA_PATH, 'LDJSON_MULTI', 'output', 'LDJSON'].join('/').freeze |
| 49 | + # @return [ String ] The file path and base name for the emitted LDJSON files. |
| 50 | + LDJSON_FILE_OUTPUT_BASE = [ DATA_PATH, 'LDJSON_MULTI', 'output', 'LDJSON' ].join('/').freeze |
89 | 51 |
|
90 |
| - # The file path and base name for the GRIDFS files to upload. |
91 |
| - # |
92 | 52 | # @return [ String ] The file path and base name for the GRIDFS files to upload.
|
93 |
| - # |
94 |
| - # @since 2.2.3 |
95 |
| - GRIDFS_MULTI_BASE = [DATA_PATH, 'GRIDFS_MULTI', 'file'].join('/').freeze |
| 53 | + GRIDFS_MULTI_BASE = [ DATA_PATH, 'GRIDFS_MULTI', 'file' ].join('/').freeze |
96 | 54 |
|
97 |
| - # The file path and base name for the outputted GRIDFS downloaded files. |
98 |
| - # |
99 |
| - # @return [ String ] The file path and base name for the outputted GRIDFS downloaded files. |
100 |
| - # |
101 |
| - # @since 2.2.3 |
102 |
| - GRIDFS_MULTI_OUTPUT_BASE = [DATA_PATH, 'GRIDFS_MULTI', 'output', 'file-output'].join('/').freeze |
| 55 | + # @return [ String ] The file path and base name for the emitted GRIDFS downloaded files. |
| 56 | + GRIDFS_MULTI_OUTPUT_BASE = [ DATA_PATH, 'GRIDFS_MULTI', 'output', 'file-output' ].join('/').freeze |
103 | 57 |
|
104 |
| - # The default number of test repetitions. |
105 |
| - # |
106 | 58 | # @return [ Integer ] The number of test repetitions.
|
107 |
| - # |
108 |
| - # @since 2.2.3 |
109 |
| - TEST_REPETITIONS = 100.freeze |
| 59 | + TEST_REPETITIONS = 100 |
110 | 60 |
|
111 |
| - # The number of default warmup repetitions of the test to do before |
112 |
| - # recording times. |
113 |
| - # |
114 |
| - # @return [ Integer ] The default number of warmup repetitions. |
| 61 | + # Convenience helper for loading the single tweet document. |
115 | 62 | #
|
116 |
| - # @since 2.2.3 |
117 |
| - WARMUP_REPETITIONS = 10.freeze |
118 |
| - |
| 63 | + # @return [ Hash ] a single parsed JSON document |
119 | 64 | def tweet_document
|
120 | 65 | Benchmarking.load_file(TWEET_DOCUMENT_FILE).first
|
121 | 66 | end
|
122 | 67 |
|
| 68 | + # Convenience helper for loading the single small document. |
| 69 | + # |
| 70 | + # @return [ Hash ] a single parsed JSON document |
123 | 71 | def small_document
|
124 | 72 | Benchmarking.load_file(SMALL_DOCUMENT_FILE).first
|
125 | 73 | end
|
126 | 74 |
|
| 75 | + # Convenience helper for loading the single large document. |
| 76 | + # |
| 77 | + # @return [ Hash ] a single parsed JSON document |
127 | 78 | def large_document
|
128 | 79 | Benchmarking.load_file(LARGE_DOCUMENT_FILE).first
|
129 | 80 | end
|
|
0 commit comments