ntl-actor 0.3.1 → 0.4.0.pre1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/actor/actor.rb +7 -147
- data/lib/actor/address.rb +18 -0
- data/lib/actor/controls/actor.rb +27 -40
- data/lib/actor/controls/address.rb +48 -0
- data/lib/actor/controls/error.rb +17 -0
- data/lib/actor/controls/message/attribute.rb +17 -0
- data/lib/actor/controls/message.rb +23 -1
- data/lib/actor/controls/thread.rb +9 -0
- data/lib/actor/controls/uuid.rb +15 -0
- data/lib/actor/controls.rb +6 -10
- data/lib/actor/destructure.rb +23 -0
- data/lib/actor/{time_unit.rb → duration.rb} +1 -1
- data/lib/actor/messages.rb +15 -0
- data/lib/actor/messaging/message.rb +5 -0
- data/lib/actor/messaging/{writer → read}/substitute.rb +13 -10
- data/lib/actor/messaging/read.rb +50 -0
- data/lib/actor/messaging/write/substitute.rb +39 -0
- data/lib/actor/messaging/write.rb +26 -0
- data/lib/actor/module/build.rb +20 -0
- data/lib/actor/module/handle_macro.rb +39 -0
- data/lib/actor/module/start.rb +19 -0
- data/lib/actor/module.rb +73 -0
- data/lib/actor/router.rb +79 -0
- data/lib/actor/start.rb +46 -0
- data/lib/actor/stream.rb +36 -0
- data/lib/actor/substitutes/kernel.rb +23 -0
- data/lib/actor/substitutes/thread.rb +39 -0
- data/lib/actor/substitutes/thread_group.rb +26 -0
- data/lib/actor/supervisor.rb +46 -52
- data/lib/actor.rb +22 -14
- metadata +29 -29
- data/lib/actor/controls/statistics/elapsed_time/average.rb +0 -21
- data/lib/actor/controls/statistics/elapsed_time/maximum.rb +0 -21
- data/lib/actor/controls/statistics/elapsed_time/minimum.rb +0 -21
- data/lib/actor/controls/statistics/elapsed_time/standard_deviation.rb +0 -38
- data/lib/actor/controls/statistics/elapsed_time.rb +0 -15
- data/lib/actor/controls/statistics/timer.rb +0 -19
- data/lib/actor/controls/statistics.rb +0 -21
- data/lib/actor/controls/time/clock.rb +0 -31
- data/lib/actor/controls/time.rb +0 -24
- data/lib/actor/message.rb +0 -23
- data/lib/actor/messaging/address.rb +0 -40
- data/lib/actor/messaging/reader/substitute.rb +0 -40
- data/lib/actor/messaging/reader.rb +0 -31
- data/lib/actor/messaging/writer.rb +0 -26
- data/lib/actor/queue/assertions.rb +0 -13
- data/lib/actor/queue/reader.rb +0 -57
- data/lib/actor/queue.rb +0 -122
- data/lib/actor/statistics/copy.rb +0 -19
- data/lib/actor/statistics/timer.rb +0 -26
- data/lib/actor/statistics.rb +0 -75
- data/lib/actor/test_fixtures/parallel_iteration.rb +0 -143
- data/lib/actor/test_fixtures/sample_actor_status.rb +0 -45
- data/lib/actor/test_fixtures.rb +0 -4
@@ -1,143 +0,0 @@
|
|
1
|
-
module Actor
|
2
|
-
module TestFixtures
|
3
|
-
class ParallelIteration
|
4
|
-
include TestBench::Fixture
|
5
|
-
|
6
|
-
attr_writer :iteration_count
|
7
|
-
attr_reader :iteration_proc
|
8
|
-
attr_writer :setup_proc
|
9
|
-
attr_writer :setup_thread_proc
|
10
|
-
attr_writer :teardown_proc
|
11
|
-
attr_accessor :test_proc
|
12
|
-
attr_reader :prose
|
13
|
-
attr_writer :thread_count
|
14
|
-
|
15
|
-
def initialize iteration_proc, prose
|
16
|
-
@iteration_proc = iteration_proc
|
17
|
-
@prose = prose
|
18
|
-
end
|
19
|
-
|
20
|
-
def self.build prose, each_iteration:, test: nil, setup: nil, setup_thread: nil, teardown: nil, iterations: nil, threads: nil
|
21
|
-
instance = new each_iteration, prose
|
22
|
-
instance.iteration_count = iterations
|
23
|
-
instance.setup_proc = setup
|
24
|
-
instance.setup_thread_proc = setup_thread
|
25
|
-
instance.teardown_proc = teardown
|
26
|
-
instance.test_proc = test
|
27
|
-
instance.thread_count = threads
|
28
|
-
instance
|
29
|
-
end
|
30
|
-
|
31
|
-
def self.call *arguments
|
32
|
-
instance = build *arguments
|
33
|
-
instance.()
|
34
|
-
end
|
35
|
-
|
36
|
-
def call
|
37
|
-
instance_exec &setup_proc
|
38
|
-
|
39
|
-
threads = thread_count.times.map do |index|
|
40
|
-
thread = Thread.new do
|
41
|
-
Thread.stop
|
42
|
-
|
43
|
-
instance_exec &setup_thread_proc
|
44
|
-
|
45
|
-
iteration_count.times do
|
46
|
-
instance_exec &iteration_proc
|
47
|
-
end
|
48
|
-
|
49
|
-
prose = "#{self.prose} (Thread: #{index + 1}/#{thread_count})"
|
50
|
-
|
51
|
-
if test_proc
|
52
|
-
test prose do
|
53
|
-
instance_exec &test_proc
|
54
|
-
end
|
55
|
-
else
|
56
|
-
context prose
|
57
|
-
end
|
58
|
-
end
|
59
|
-
thread.abort_on_exception = true
|
60
|
-
thread
|
61
|
-
end
|
62
|
-
|
63
|
-
Thread.pass until threads.all? &:stop?
|
64
|
-
|
65
|
-
context "Started #{thread_count} threads; each will iterate #{iteration_count} times"
|
66
|
-
|
67
|
-
t0 = Time.now
|
68
|
-
|
69
|
-
threads.each &:wakeup
|
70
|
-
threads.each &:join
|
71
|
-
|
72
|
-
t1 = Time.now
|
73
|
-
|
74
|
-
elapsed_time = t1 - t0
|
75
|
-
|
76
|
-
total_iterations = thread_count * iteration_count
|
77
|
-
|
78
|
-
iterations_per_second = Rational total_iterations, elapsed_time
|
79
|
-
|
80
|
-
context "Finished %i iterations across %i threads in %.2fs; %.2f iterations per second" %
|
81
|
-
[total_iterations, thread_count, elapsed_time, iterations_per_second]
|
82
|
-
|
83
|
-
return iteration_count, thread_count
|
84
|
-
|
85
|
-
ensure
|
86
|
-
instance_exec &teardown_proc
|
87
|
-
end
|
88
|
-
|
89
|
-
def iteration_count
|
90
|
-
@iteration_count ||= Defaults.iteration_count
|
91
|
-
end
|
92
|
-
|
93
|
-
def print_debug receiver
|
94
|
-
str = receiver.inspect
|
95
|
-
str << "\n"
|
96
|
-
|
97
|
-
$stdout.write str
|
98
|
-
end
|
99
|
-
|
100
|
-
def setup_proc
|
101
|
-
@setup_proc ||= proc {}
|
102
|
-
end
|
103
|
-
|
104
|
-
def setup_thread_proc
|
105
|
-
@setup_thread_proc ||= proc {}
|
106
|
-
end
|
107
|
-
|
108
|
-
def teardown_proc
|
109
|
-
@teardown_proc ||= proc {}
|
110
|
-
end
|
111
|
-
|
112
|
-
def thread
|
113
|
-
Thread.current
|
114
|
-
end
|
115
|
-
|
116
|
-
def thread_count
|
117
|
-
@thread_count ||= Defaults.thread_count
|
118
|
-
end
|
119
|
-
|
120
|
-
module Defaults
|
121
|
-
def self.iteration_count
|
122
|
-
if ENV['STRESS_TEST'] == 'high'
|
123
|
-
10_000
|
124
|
-
elsif ENV['STRESS_TEST'] == 'low'
|
125
|
-
2_500
|
126
|
-
else
|
127
|
-
100
|
128
|
-
end
|
129
|
-
end
|
130
|
-
|
131
|
-
def self.thread_count
|
132
|
-
if ENV['STRESS_TEST'] == 'high'
|
133
|
-
100
|
134
|
-
elsif ENV['STRESS_TEST'] == 'low'
|
135
|
-
25
|
136
|
-
else
|
137
|
-
2
|
138
|
-
end
|
139
|
-
end
|
140
|
-
end
|
141
|
-
end
|
142
|
-
end
|
143
|
-
end
|
@@ -1,45 +0,0 @@
|
|
1
|
-
module Actor
|
2
|
-
module TestFixtures
|
3
|
-
class SampleActorStatus
|
4
|
-
include TestBench::Fixture
|
5
|
-
|
6
|
-
attr_reader :reader
|
7
|
-
attr_reader :reply_address
|
8
|
-
attr_reader :writer
|
9
|
-
|
10
|
-
def initialize writer, reply_address, reader
|
11
|
-
@reader = reader
|
12
|
-
@reply_address = reply_address
|
13
|
-
@writer = writer
|
14
|
-
end
|
15
|
-
|
16
|
-
def self.call prose, address:, test:
|
17
|
-
reply_address = Messaging::Address.build
|
18
|
-
reader = Messaging::Reader.build reply_address
|
19
|
-
|
20
|
-
writer = Messaging::Writer.build address
|
21
|
-
|
22
|
-
instance = new writer, reply_address, reader
|
23
|
-
instance.(prose, &test)
|
24
|
-
end
|
25
|
-
|
26
|
-
def call test_prose, &block
|
27
|
-
writer.(record_status_message)
|
28
|
-
|
29
|
-
status_0 = reader.(wait: true)
|
30
|
-
|
31
|
-
writer.(record_status_message)
|
32
|
-
|
33
|
-
status_1 = reader.(wait: true)
|
34
|
-
|
35
|
-
test test_prose do
|
36
|
-
block.(status_1, status_0)
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
def record_status_message
|
41
|
-
Message::RecordStatus.new reply_address
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
data/lib/actor/test_fixtures.rb
DELETED