155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
|
# File 'lib/praxis/plugins/praxis_mapper_plugin.rb', line 155
def self.detailed(identity_map)
stats_by_model = identity_map.query_statistics.sum_totals_by_model
stats_total = identity_map.query_statistics.sum_totals
fields = [ :query_count, :records_loaded, :datastore_interactions, :datastore_interaction_time]
rows = []
total_models_loaded = 0
stats_by_model.each do |model, totals|
total_values = totals.values_at(*fields)
self.round_fields_at( total_values , [fields.index(:datastore_interaction_time)])
row = [ model ] + total_values
models_loaded = identity_map.all(model).size
total_models_loaded += models_loaded
row << models_loaded
rows << row
end
rows << :separator
stats_total_values = stats_total.values_at(*fields)
self.round_fields_at(stats_total_values , [fields.index(:datastore_interaction_time)])
rows << [ "All Models" ] + stats_total_values + [total_models_loaded]
table = Terminal::Table.new \
:rows => rows,
:title => "Praxis::Mapper Statistics",
:headings => [ "Model", "# Queries", "Records Loaded", "Interactions", "Time(sec)", "Models Loaded" ]
table.align_column(1, :right)
table.align_column(2, :right)
table.align_column(3, :right)
table.align_column(4, :right)
table.align_column(5, :right)
Praxis::Application.instance.logger.info "Praxis::Mapper Statistics:\n#{table.to_s}"
end
|