-
Notifications
You must be signed in to change notification settings - Fork 6
/
measure_lr.rb
48 lines (40 loc) · 1.08 KB
/
measure_lr.rb
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
require 'bundler/setup'
require "active_record"
require 'light_record'
#require "stackprof"
#require "flamegraph"
require 'memory_profiler'
require "process_memory"
class ARQuestion < ActiveRecord::Base
self.table_name = "sample"
end
ActiveRecord::Base.establish_connection(
adapter: 'mysql2',
database: 'light_record',
host: 'localhost',
username: 'root',
password: ''
)
ARQuestion.first
#filename = "1.html"
#Flamegraph.generate(filename) do
#end
report = MemoryProfiler.report do
records = []
records_data = []
GC.start
start_mem = ProcessMemory.current_mb
start_time = Time.now
puts "#{Time.now} --- RAM: #{start_mem}mb"
ARQuestion.all.limit(5000).light_records_each do |record|
records_data << record.attributes.to_json #"#{record.rev_id} #{record.title} #{record.serial_id} #{record.question}"
records << record
#records_json << record.to_json
end
puts "Time: #{Time.now - start_time}"
end_mem = ProcessMemory.current_mb
puts "#{Time.now} --- RAM: #{end_mem}mb"
puts "Diff: #{end_mem - start_mem}mb"
puts records.size
end
report.pretty_print