-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathuuids.rb
More file actions
51 lines (39 loc) · 903 Bytes
/
uuids.rb
File metadata and controls
51 lines (39 loc) · 903 Bytes
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
# frozen_string_literal: true
require "get_process_mem"
require "securerandom"
require_relative "../lib/goru"
class Worker
include Goru
def initialize
@results = []
end
attr_reader :results
def call
100_000.times do |index|
go(0) { |routine|
state = routine.state
if state >= 10
routine.finished
else
@results << SecureRandom.uuid
routine.update(state + 1)
end
}
# Use this to see how fast things are without concurrency.
#
# 10.times do |j|
# @results << SecureRandom.uuid
# end
end
end
end
def mem
GetProcessMem.new.mb.round(0)
end
start = Time.now
worker = Worker.new
worker.call
# Wait before we attempt to get results (ultimately need some kind of future).
#
Goru::Scheduler.wait
puts "got #{worker.results.count} in #{Time.now - start}, using #{mem}MB"