roby 0.7.3 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +7 -5
- data/Manifest.txt +91 -16
- data/README.txt +24 -24
- data/Rakefile +92 -64
- data/app/config/app.yml +42 -43
- data/app/config/init.rb +26 -0
- data/benchmark/alloc_misc.rb +123 -0
- data/benchmark/discovery_latency.rb +67 -0
- data/benchmark/garbage_collection.rb +48 -0
- data/benchmark/genom.rb +31 -0
- data/benchmark/transactions.rb +62 -0
- data/bin/roby +1 -1
- data/bin/roby-log +16 -6
- data/doc/guide/.gitignore +2 -0
- data/doc/guide/config.yaml +34 -0
- data/doc/guide/ext/init.rb +14 -0
- data/doc/guide/ext/previous_next.rb +40 -0
- data/doc/guide/ext/rdoc_links.rb +33 -0
- data/doc/guide/index.rdoc +16 -0
- data/doc/guide/overview.rdoc +62 -0
- data/doc/guide/plan_modifications.rdoc +67 -0
- data/doc/guide/src/abstraction/achieve_with.page +8 -0
- data/doc/guide/src/abstraction/forwarding.page +8 -0
- data/doc/guide/src/abstraction/hierarchy.page +19 -0
- data/doc/guide/src/abstraction/index.page +28 -0
- data/doc/guide/src/abstraction/task_models.page +13 -0
- data/doc/guide/src/basics.template +6 -0
- data/doc/guide/src/basics/app.page +139 -0
- data/doc/guide/src/basics/code_examples.page +33 -0
- data/doc/guide/src/basics/dry.page +69 -0
- data/doc/guide/src/basics/errors.page +443 -0
- data/doc/guide/src/basics/events.page +179 -0
- data/doc/guide/src/basics/hierarchy.page +275 -0
- data/doc/guide/src/basics/index.page +11 -0
- data/doc/guide/src/basics/log_replay/goForward_1.png +0 -0
- data/doc/guide/src/basics/log_replay/goForward_2.png +0 -0
- data/doc/guide/src/basics/log_replay/goForward_3.png +0 -0
- data/doc/guide/src/basics/log_replay/goForward_4.png +0 -0
- data/doc/guide/src/basics/log_replay/goForward_5.png +0 -0
- data/doc/guide/src/basics/log_replay/hierarchy_error_1.png +0 -0
- data/doc/guide/src/basics/log_replay/hierarchy_error_2.png +0 -0
- data/doc/guide/src/basics/log_replay/hierarchy_error_3.png +0 -0
- data/doc/guide/src/basics/log_replay/plan_repair_1.png +0 -0
- data/doc/guide/src/basics/log_replay/plan_repair_2.png +0 -0
- data/doc/guide/src/basics/log_replay/plan_repair_3.png +0 -0
- data/doc/guide/src/basics/log_replay/plan_repair_4.png +0 -0
- data/doc/guide/src/basics/log_replay/roby_log_main_window.png +0 -0
- data/doc/guide/src/basics/log_replay/roby_log_relation_window.png +0 -0
- data/doc/guide/src/basics/log_replay/roby_replay_event_representation.png +0 -0
- data/doc/guide/src/basics/plan_objects.page +71 -0
- data/doc/guide/src/basics/relations_display.page +203 -0
- data/doc/guide/src/basics/roby_cycle_overview.png +0 -0
- data/doc/guide/src/basics/shell.page +102 -0
- data/doc/guide/src/basics/summary.page +32 -0
- data/doc/guide/src/basics/tasks.page +357 -0
- data/doc/guide/src/basics_shell_header.txt +16 -0
- data/doc/guide/src/cycle/cycle-overview.png +0 -0
- data/doc/guide/src/cycle/cycle-overview.svg +208 -0
- data/doc/guide/src/cycle/error_handling.page +168 -0
- data/doc/guide/src/cycle/error_instantaneous_repair.png +0 -0
- data/doc/guide/src/cycle/error_instantaneous_repair.svg +1224 -0
- data/doc/guide/src/cycle/garbage_collection.page +10 -0
- data/doc/guide/src/cycle/index.page +23 -0
- data/doc/guide/src/cycle/propagation.page +154 -0
- data/doc/guide/src/cycle/propagation_diamond.png +0 -0
- data/doc/guide/src/cycle/propagation_diamond.svg +1279 -0
- data/doc/guide/src/default.css +319 -0
- data/doc/guide/src/default.template +74 -0
- data/doc/guide/src/htmldoc.metainfo +20 -0
- data/doc/guide/src/htmldoc.virtual +18 -0
- data/doc/guide/src/images/bodybg.png +0 -0
- data/doc/guide/src/images/contbg.png +0 -0
- data/doc/guide/src/images/footerbg.png +0 -0
- data/doc/guide/src/images/gradient1.png +0 -0
- data/doc/guide/src/images/gradient2.png +0 -0
- data/doc/guide/src/index.page +7 -0
- data/doc/guide/src/introduction/index.page +29 -0
- data/doc/guide/src/introduction/install.page +133 -0
- data/doc/{papers.rdoc → guide/src/introduction/publications.page} +5 -2
- data/doc/{videos.rdoc → guide/src/introduction/videos.page} +4 -2
- data/doc/guide/src/plugins/fault_tolerance.page +44 -0
- data/doc/guide/src/plugins/index.page +11 -0
- data/doc/guide/src/plugins/subsystems.page +45 -0
- data/doc/guide/src/relations/dependency.page +89 -0
- data/doc/guide/src/relations/index.page +12 -0
- data/doc/misc/update_github +24 -0
- data/doc/tutorials/02-GoForward.rdoc +3 -3
- data/ext/graph/graph.cc +46 -0
- data/lib/roby.rb +57 -22
- data/lib/roby/app.rb +132 -112
- data/lib/roby/app/plugins/rake.rb +21 -0
- data/lib/roby/app/rake.rb +0 -7
- data/lib/roby/app/run.rb +1 -1
- data/lib/roby/app/scripts/distributed.rb +1 -2
- data/lib/roby/app/scripts/generate/bookmarks.rb +1 -1
- data/lib/roby/app/scripts/results.rb +2 -1
- data/lib/roby/app/scripts/run.rb +6 -2
- data/lib/roby/app/scripts/shell.rb +11 -11
- data/lib/roby/config.rb +1 -1
- data/lib/roby/decision_control.rb +62 -3
- data/lib/roby/distributed.rb +4 -0
- data/lib/roby/distributed/base.rb +8 -0
- data/lib/roby/distributed/communication.rb +12 -8
- data/lib/roby/distributed/connection_space.rb +61 -44
- data/lib/roby/distributed/distributed_object.rb +1 -1
- data/lib/roby/distributed/notifications.rb +22 -30
- data/lib/roby/distributed/peer.rb +13 -8
- data/lib/roby/distributed/proxy.rb +5 -5
- data/lib/roby/distributed/subscription.rb +4 -4
- data/lib/roby/distributed/transaction.rb +3 -3
- data/lib/roby/event.rb +176 -110
- data/lib/roby/exceptions.rb +12 -4
- data/lib/roby/execution_engine.rb +1604 -0
- data/lib/roby/external_process_task.rb +225 -0
- data/lib/roby/graph.rb +0 -6
- data/lib/roby/interface.rb +221 -137
- data/lib/roby/log/console.rb +5 -3
- data/lib/roby/log/data_stream.rb +94 -16
- data/lib/roby/log/dot.rb +8 -8
- data/lib/roby/log/event_stream.rb +13 -3
- data/lib/roby/log/file.rb +43 -18
- data/lib/roby/log/gui/basic_display_ui.rb +89 -0
- data/lib/roby/log/gui/chronicle_view_ui.rb +90 -0
- data/lib/roby/log/gui/data_displays.rb +4 -5
- data/lib/roby/log/gui/data_displays_ui.rb +146 -0
- data/lib/roby/log/gui/relations.rb +18 -18
- data/lib/roby/log/gui/relations_ui.rb +120 -0
- data/lib/roby/log/gui/relations_view_ui.rb +144 -0
- data/lib/roby/log/gui/replay.rb +41 -13
- data/lib/roby/log/gui/replay_controls.rb +3 -0
- data/lib/roby/log/gui/replay_controls.ui +133 -110
- data/lib/roby/log/gui/replay_controls_ui.rb +249 -0
- data/lib/roby/log/hooks.rb +19 -18
- data/lib/roby/log/logger.rb +7 -6
- data/lib/roby/log/notifications.rb +4 -4
- data/lib/roby/log/plan_rebuilder.rb +20 -22
- data/lib/roby/log/relations.rb +44 -16
- data/lib/roby/log/server.rb +1 -4
- data/lib/roby/log/timings.rb +88 -19
- data/lib/roby/plan-object.rb +135 -11
- data/lib/roby/plan.rb +408 -224
- data/lib/roby/planning/loops.rb +32 -25
- data/lib/roby/planning/model.rb +157 -51
- data/lib/roby/planning/task.rb +47 -20
- data/lib/roby/query.rb +128 -92
- data/lib/roby/relations.rb +254 -136
- data/lib/roby/relations/conflicts.rb +6 -9
- data/lib/roby/relations/dependency.rb +358 -0
- data/lib/roby/relations/ensured.rb +0 -1
- data/lib/roby/relations/error_handling.rb +0 -1
- data/lib/roby/relations/events.rb +0 -2
- data/lib/roby/relations/executed_by.rb +26 -11
- data/lib/roby/relations/planned_by.rb +14 -14
- data/lib/roby/robot.rb +46 -0
- data/lib/roby/schedulers/basic.rb +34 -0
- data/lib/roby/standalone.rb +4 -0
- data/lib/roby/standard_errors.rb +21 -15
- data/lib/roby/state/events.rb +5 -4
- data/lib/roby/support.rb +107 -6
- data/lib/roby/task-operations.rb +23 -19
- data/lib/roby/task.rb +522 -148
- data/lib/roby/task_index.rb +80 -0
- data/lib/roby/test/common.rb +283 -44
- data/lib/roby/test/distributed.rb +53 -37
- data/lib/roby/test/testcase.rb +9 -204
- data/lib/roby/test/tools.rb +3 -3
- data/lib/roby/transactions.rb +154 -111
- data/lib/roby/transactions/proxy.rb +40 -7
- data/manifest.xml +20 -0
- data/plugins/fault_injection/README.txt +0 -3
- data/plugins/fault_injection/Rakefile +2 -8
- data/plugins/fault_injection/app.rb +1 -1
- data/plugins/fault_injection/fault_injection.rb +3 -3
- data/plugins/fault_injection/test/test_fault_injection.rb +19 -25
- data/plugins/subsystems/README.txt +0 -3
- data/plugins/subsystems/Rakefile +2 -7
- data/plugins/subsystems/app.rb +27 -16
- data/plugins/subsystems/test/app/config/init.rb +3 -0
- data/plugins/subsystems/test/app/planners/main.rb +1 -1
- data/plugins/subsystems/test/app/tasks/services.rb +1 -1
- data/plugins/subsystems/test/test_subsystems.rb +23 -16
- data/test/distributed/test_communication.rb +32 -15
- data/test/distributed/test_connection.rb +28 -26
- data/test/distributed/test_execution.rb +59 -54
- data/test/distributed/test_mixed_plan.rb +34 -34
- data/test/distributed/test_plan_notifications.rb +26 -26
- data/test/distributed/test_protocol.rb +57 -48
- data/test/distributed/test_query.rb +11 -7
- data/test/distributed/test_remote_plan.rb +71 -71
- data/test/distributed/test_transaction.rb +50 -47
- data/test/mockups/external_process +28 -0
- data/test/planning/test_loops.rb +163 -119
- data/test/planning/test_model.rb +3 -3
- data/test/planning/test_task.rb +27 -7
- data/test/relations/test_conflicts.rb +3 -3
- data/test/relations/test_dependency.rb +324 -0
- data/test/relations/test_ensured.rb +2 -2
- data/test/relations/test_executed_by.rb +94 -19
- data/test/relations/test_planned_by.rb +11 -9
- data/test/suite_core.rb +6 -3
- data/test/suite_distributed.rb +1 -0
- data/test/suite_planning.rb +1 -0
- data/test/suite_relations.rb +2 -2
- data/test/tasks/test_external_process.rb +126 -0
- data/test/{test_thread_task.rb → tasks/test_thread_task.rb} +17 -20
- data/test/test_bgl.rb +21 -1
- data/test/test_event.rb +229 -155
- data/test/test_exceptions.rb +79 -80
- data/test/test_execution_engine.rb +987 -0
- data/test/test_gui.rb +1 -1
- data/test/test_interface.rb +11 -5
- data/test/test_log.rb +18 -7
- data/test/test_log_server.rb +1 -0
- data/test/test_plan.rb +229 -395
- data/test/test_query.rb +193 -35
- data/test/test_relations.rb +88 -8
- data/test/test_state.rb +55 -37
- data/test/test_support.rb +1 -1
- data/test/test_task.rb +371 -218
- data/test/test_testcase.rb +32 -16
- data/test/test_transactions.rb +211 -170
- data/test/test_transactions_proxy.rb +37 -19
- metadata +169 -71
- data/.gitignore +0 -29
- data/doc/styles/allison.css +0 -314
- data/doc/styles/allison.js +0 -316
- data/doc/styles/allison.rb +0 -276
- data/doc/styles/jamis.rb +0 -593
- data/lib/roby/control.rb +0 -746
- data/lib/roby/executives/simple.rb +0 -30
- data/lib/roby/propagation.rb +0 -562
- data/lib/roby/relations/hierarchy.rb +0 -239
- data/lib/roby/transactions/updates.rb +0 -139
- data/test/relations/test_hierarchy.rb +0 -158
- data/test/test_control.rb +0 -399
- data/test/test_propagation.rb +0 -210
data/app/config/app.yml
CHANGED
@@ -1,17 +1,6 @@
|
|
1
1
|
# Control configuration
|
2
|
-
|
3
|
-
#
|
4
|
-
# abort_on_exception: false
|
5
|
-
# Abort if an application exception occurs
|
6
|
-
# abort_on_application_exception: false
|
7
|
-
|
8
|
-
# The executive. Set to 'none' to disable.
|
9
|
-
# The executive object determines, in the current plan, what are
|
10
|
-
# the tasks which must be started. The 'simple' executive starts
|
11
|
-
# all tasks that have no predecessors.
|
12
|
-
executive: simple
|
13
|
-
|
14
|
-
# The length of a cycle (in seconds)
|
2
|
+
engine:
|
3
|
+
# The length of a cycle (in seconds). It defaults to 100ms.
|
15
4
|
# cycle: 0.1
|
16
5
|
|
17
6
|
# Logging configuration
|
@@ -19,10 +8,25 @@ log:
|
|
19
8
|
# Where log files go
|
20
9
|
# dir: log/
|
21
10
|
|
22
|
-
# Log system events
|
11
|
+
# Log system events. It can be either true, false or stats. If true, all
|
12
|
+
# plan-level events are logged, allowing to use the roby-log GUI to replay
|
13
|
+
# the plans. If false, nothing is logged. If set to stats, only execution
|
14
|
+
# statistics are logged. This mode is useful to monitor execution latencies
|
15
|
+
# without having the big impact of full logging.
|
16
|
+
#
|
17
|
+
# See the roby-log tool to read the generated files, Roby::Log::Logfile to read the
|
18
|
+
# files from a Ruby script and Roby::Log::Timings for reading and using per-cycle
|
19
|
+
# statistics.
|
20
|
+
#
|
21
|
+
# The default is stats
|
22
|
+
#
|
23
23
|
# events: true
|
24
24
|
|
25
|
-
#
|
25
|
+
# Set to false to disables the log server and true to enable it (it is enabled by
|
26
|
+
# default). The log server allows to display the controller state remotely by using the
|
27
|
+
# <tt>roby-log</tt> tool. Note that it is completely separated from the Roby remote
|
28
|
+
# shell, which is always enabled.
|
29
|
+
#
|
26
30
|
# server: false
|
27
31
|
#
|
28
32
|
# ... or configure it
|
@@ -32,17 +36,32 @@ log:
|
|
32
36
|
# # The discovery period
|
33
37
|
# period: 10
|
34
38
|
|
35
|
-
# Logging levels.
|
36
|
-
#
|
37
|
-
#
|
38
|
-
#
|
39
|
-
#
|
39
|
+
# Logging levels.
|
40
|
+
#
|
41
|
+
# Logging in Roby is controlled per-module in a hierarchical way. It means that to get
|
42
|
+
# debugging output for the whole framework, set
|
43
|
+
#
|
44
|
+
# levels:
|
45
|
+
# roby: DEBUG
|
46
|
+
#
|
47
|
+
# now, if you want to have it do debug for everything but the classes in
|
48
|
+
# Roby::Distributed, do
|
49
|
+
#
|
50
|
+
# levels:
|
51
|
+
# roby: DEBUG
|
52
|
+
# roby/distributed: INFO
|
53
|
+
#
|
54
|
+
# The available logging levels are DEBUG, INFO, WARN and FATAL. The output can be
|
55
|
+
# redirected in a file using level:filename, in which case 'filename' is relative to the
|
56
|
+
# log directory. Any occurence of 'ROBOT' in filename is replaced by the robot name. For
|
57
|
+
# instance, in a 'dala' robot, the following setup would redirect the debugging outut of
|
58
|
+
# Roby::Distributed classes into data-distributed.log:
|
40
59
|
#
|
41
60
|
# levels:
|
42
|
-
# roby: INFO
|
43
|
-
# roby/planning: DEBUG
|
44
61
|
# roby/distributed: DEBUG:ROBOT-distributed.log
|
45
|
-
#
|
62
|
+
#
|
63
|
+
# Log files are saved in the log directory (controlled by the 'dir' option above, it is
|
64
|
+
# 'log' by default).
|
46
65
|
|
47
66
|
# dRoby neighbour discovery
|
48
67
|
discovery:
|
@@ -62,26 +81,6 @@ droby:
|
|
62
81
|
# 'host:port', or just ':port'
|
63
82
|
# host: ":48902"
|
64
83
|
|
65
|
-
# Genom configuration
|
66
|
-
genom:
|
67
|
-
# The memory size allocated for H2
|
68
|
-
# mem_size: 4000000
|
69
|
-
# If true, do not remove H2 devices when the application quit
|
70
|
-
# keep_h2: false
|
71
|
-
|
72
|
-
# Pocosim configuration
|
73
|
-
pocosim:
|
74
|
-
# The host of the GDHE display
|
75
|
-
# display: localhost
|
76
|
-
|
77
|
-
# An initialization script to display the scene on GDHE. The file is searched
|
78
|
-
# in the data/ director
|
79
|
-
# gdhe: lousa.gdhe
|
80
|
-
|
81
|
-
# The Gazebo world file for pocosim/gazebo simulations. The file is searched
|
82
|
-
# in the data/ directory
|
83
|
-
# gazebo: lousa.world
|
84
|
-
|
85
84
|
# Per-robot configuration. In these, you can override global options, or set
|
86
85
|
# new options.
|
87
86
|
# dala:
|
data/app/config/init.rb
CHANGED
@@ -5,3 +5,29 @@
|
|
5
5
|
# Roby.app.using 'fault_injection'
|
6
6
|
# Roby.app.using 'subsystems'
|
7
7
|
|
8
|
+
##############################
|
9
|
+
# Sets some configuration options
|
10
|
+
#
|
11
|
+
# If true, the engine aborts if an uncaught task or event exception is
|
12
|
+
# received. Defaults to false, as Roby has meaningful ways to handle those
|
13
|
+
# Roby.app.abort_on_exception = false
|
14
|
+
#
|
15
|
+
# If true, the engine aborts if an exception is raised outside of the reach of
|
16
|
+
# the plan-based error management. Defaults to true, as there is no safe ways
|
17
|
+
# to handle those.
|
18
|
+
# Roby.app.abort_on_application_exception = true
|
19
|
+
|
20
|
+
##############################
|
21
|
+
# Set the decision control object to be used during execution (can also be
|
22
|
+
# done per-robot)
|
23
|
+
#
|
24
|
+
# Roby.control = Roby::DecisionControl.new
|
25
|
+
|
26
|
+
|
27
|
+
##############################
|
28
|
+
# Set the scheduler object to be used during execution (can also be done
|
29
|
+
# per-robot by setting it in config/#{ROBOT}.rb)
|
30
|
+
|
31
|
+
require 'roby/schedulers/basic'
|
32
|
+
Roby.scheduler = Roby::Schedulers::Basic.new
|
33
|
+
|
@@ -0,0 +1,123 @@
|
|
1
|
+
require 'utilrb/objectstats'
|
2
|
+
require 'utilrb/value_set'
|
3
|
+
require 'enumerator'
|
4
|
+
require 'set'
|
5
|
+
|
6
|
+
GC.disable
|
7
|
+
|
8
|
+
puts "==== Iteration"
|
9
|
+
[(1..10_000), (1..10_000).to_a, (1..10_000).to_value_set, (1..10_000).enum_for, (1..10_000).to_set].each do |set|
|
10
|
+
before = ObjectSpace.live_objects
|
11
|
+
for obj in set
|
12
|
+
10
|
13
|
+
end
|
14
|
+
after = ObjectSpace.live_objects
|
15
|
+
puts "#{set.class} for: #{after - before}"
|
16
|
+
|
17
|
+
before = ObjectSpace.live_objects
|
18
|
+
set.each { |obj| 10 }
|
19
|
+
after = ObjectSpace.live_objects
|
20
|
+
puts "#{set.class} each: #{after - before}"
|
21
|
+
end
|
22
|
+
|
23
|
+
puts "\n===== Method calls"
|
24
|
+
def bm_args_yield(a, b)
|
25
|
+
yield(a, b) if block_given?
|
26
|
+
end
|
27
|
+
def bm_args_yield_through_block(a, b, &block)
|
28
|
+
block.call(a, b) if block
|
29
|
+
end
|
30
|
+
|
31
|
+
def bm_method_call
|
32
|
+
end
|
33
|
+
|
34
|
+
def bm_yield
|
35
|
+
yield
|
36
|
+
end
|
37
|
+
def bm_block_yield(&block)
|
38
|
+
yield
|
39
|
+
end
|
40
|
+
|
41
|
+
def bm_block(do_call, &block)
|
42
|
+
block.call if do_call
|
43
|
+
end
|
44
|
+
|
45
|
+
class Test
|
46
|
+
def bla
|
47
|
+
end
|
48
|
+
end
|
49
|
+
class Foo < Test
|
50
|
+
def bla
|
51
|
+
super
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
|
56
|
+
before = ObjectSpace.live_objects
|
57
|
+
bm_method_call
|
58
|
+
after = ObjectSpace.live_objects
|
59
|
+
puts "Method call: #{after - before}"
|
60
|
+
|
61
|
+
test = Foo.new
|
62
|
+
before = ObjectSpace.live_objects
|
63
|
+
test.bla
|
64
|
+
after = ObjectSpace.live_objects
|
65
|
+
puts "Method call with super: #{after - before}"
|
66
|
+
|
67
|
+
before = ObjectSpace.live_objects
|
68
|
+
bm_method_call { 10 }
|
69
|
+
after = ObjectSpace.live_objects
|
70
|
+
puts "Method call with block m(): #{after - before}"
|
71
|
+
|
72
|
+
before = ObjectSpace.live_objects
|
73
|
+
bm_block(false) { 10 }
|
74
|
+
after = ObjectSpace.live_objects
|
75
|
+
puts "Method call with block m(&block): #{after - before}"
|
76
|
+
|
77
|
+
before = ObjectSpace.live_objects
|
78
|
+
bm_yield { 10 }
|
79
|
+
after = ObjectSpace.live_objects
|
80
|
+
puts "Yield: #{after - before}"
|
81
|
+
|
82
|
+
before = ObjectSpace.live_objects
|
83
|
+
bm_block(true) { 10 }
|
84
|
+
after = ObjectSpace.live_objects
|
85
|
+
puts "Block & #call: #{after - before}"
|
86
|
+
|
87
|
+
before = ObjectSpace.live_objects
|
88
|
+
bm_block_yield { 10 }
|
89
|
+
after = ObjectSpace.live_objects
|
90
|
+
puts "Block and yield: #{after - before}"
|
91
|
+
|
92
|
+
p = Proc.new { 10 }
|
93
|
+
before = ObjectSpace.live_objects
|
94
|
+
p.call
|
95
|
+
after = ObjectSpace.live_objects
|
96
|
+
puts "Proc#call: #{after - before}"
|
97
|
+
|
98
|
+
puts "\n=== Exceptions"
|
99
|
+
def bm_exception
|
100
|
+
rescue
|
101
|
+
ensure
|
102
|
+
end
|
103
|
+
before = ObjectSpace.live_objects
|
104
|
+
begin
|
105
|
+
rescue Exception
|
106
|
+
ensure
|
107
|
+
end
|
108
|
+
after = ObjectSpace.live_objects
|
109
|
+
puts "begin-rescue-ensure: #{after - before}"
|
110
|
+
|
111
|
+
before = ObjectSpace.live_objects
|
112
|
+
bm_exception
|
113
|
+
after = ObjectSpace.live_objects
|
114
|
+
puts "begin-rescue-ensure method: #{after - before}"
|
115
|
+
|
116
|
+
puts "\n=== Misc"
|
117
|
+
before = ObjectSpace.live_objects
|
118
|
+
defined? yield
|
119
|
+
after = ObjectSpace.live_objects
|
120
|
+
puts "defined?: #{after - before}"
|
121
|
+
|
122
|
+
|
123
|
+
|
@@ -0,0 +1,67 @@
|
|
1
|
+
TOP_SRC_DIR = File.expand_path( File.join(File.dirname(__FILE__), '..') )
|
2
|
+
$LOAD_PATH.unshift TOP_SRC_DIR
|
3
|
+
$LOAD_PATH.unshift File.join(TOP_SRC_DIR, 'test')
|
4
|
+
|
5
|
+
require 'roby/distributed/connection_space'
|
6
|
+
|
7
|
+
TEST_SIZE=20
|
8
|
+
BASE_PERIOD=0.5
|
9
|
+
|
10
|
+
include Roby
|
11
|
+
include Roby::Distributed
|
12
|
+
BROADCAST = (1..10).map { |i| "127.0.0.#{i}" }
|
13
|
+
|
14
|
+
def test(discovery_period)
|
15
|
+
start_r, start_w= IO.pipe
|
16
|
+
quit_r, quit_w = IO.pipe
|
17
|
+
remote_pid = fork do
|
18
|
+
start_r.close
|
19
|
+
quit_w.close
|
20
|
+
|
21
|
+
DRb.start_service
|
22
|
+
Distributed.state = ConnectionSpace.new :period => discovery_period, :ring_discovery => true, :ring_broadcast => BROADCAST
|
23
|
+
Distributed.publish :bind => '127.0.0.2'
|
24
|
+
|
25
|
+
start_w.write('OK')
|
26
|
+
quit_r.read(2)
|
27
|
+
Distributed.unpublish
|
28
|
+
end
|
29
|
+
start_w.close
|
30
|
+
quit_r.close
|
31
|
+
start_r.read(2)
|
32
|
+
|
33
|
+
DRb.start_service
|
34
|
+
Distributed.state = ConnectionSpace.new :period => discovery_period, :ring_discovery => true, :ring_broadcast => BROADCAST
|
35
|
+
Distributed.publish :bind => '127.0.0.1'
|
36
|
+
|
37
|
+
Distributed.state.start_neighbour_discovery
|
38
|
+
Distributed.state.wait_discovery
|
39
|
+
raise unless Distributed.neighbours.find { |n| n.name == "#{Socket.gethostname}-#{remote_pid}" }
|
40
|
+
|
41
|
+
ensure
|
42
|
+
Distributed.unpublish
|
43
|
+
start_r.close
|
44
|
+
quit_w.write('OK')
|
45
|
+
Process.waitpid(remote_pid)
|
46
|
+
end
|
47
|
+
|
48
|
+
period = BASE_PERIOD
|
49
|
+
error_count = 0
|
50
|
+
while (error_count.to_f / TEST_SIZE) < 0.1
|
51
|
+
error_count = 0
|
52
|
+
STDERR.print "#{period}"
|
53
|
+
(0..TEST_SIZE).each do |i|
|
54
|
+
begin
|
55
|
+
test(period)
|
56
|
+
rescue Exception => e
|
57
|
+
if e.class != RuntimeError
|
58
|
+
STDERR.puts e.message
|
59
|
+
end
|
60
|
+
error_count += 1
|
61
|
+
end
|
62
|
+
STDERR.print "\r#{period} (#{i}|#{error_count}|#{TEST_SIZE})"
|
63
|
+
end
|
64
|
+
STDERR.puts
|
65
|
+
period /= 2
|
66
|
+
end
|
67
|
+
|
@@ -0,0 +1,48 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
require 'roby'
|
3
|
+
require 'benchmark'
|
4
|
+
include Roby
|
5
|
+
|
6
|
+
TASK_COUNT = 100
|
7
|
+
EVENT_COUNT = 50
|
8
|
+
RELATION_COUNT = 200
|
9
|
+
|
10
|
+
tasks = (1..TASK_COUNT).map { Task.new }
|
11
|
+
events = (1..EVENT_COUNT).map { EventGenerator.new }
|
12
|
+
|
13
|
+
plan = Plan.new
|
14
|
+
tasks.each { |t| plan.permanent(t) }
|
15
|
+
plan.discover(events)
|
16
|
+
|
17
|
+
objects = tasks + events
|
18
|
+
RELATION_COUNT.times do
|
19
|
+
parent = objects.random_element
|
20
|
+
child = objects.random_element
|
21
|
+
next if parent == child
|
22
|
+
|
23
|
+
if parent.kind_of?(EventGenerator)
|
24
|
+
if !child.kind_of?(EventGenerator)
|
25
|
+
child = child.bound_events.random_element.last
|
26
|
+
end
|
27
|
+
elsif child.kind_of?(EventGenerator)
|
28
|
+
parent = parent.bound_events.random_element.last
|
29
|
+
end
|
30
|
+
|
31
|
+
relation = if parent.kind_of?(EventGenerator)
|
32
|
+
EventStructure.relations.random_element
|
33
|
+
else
|
34
|
+
TaskStructure.relations.random_element
|
35
|
+
end
|
36
|
+
|
37
|
+
begin
|
38
|
+
parent.add_child_object(child, relation, :success => [], :failure => [])
|
39
|
+
rescue CycleFoundError
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
Benchmark.bm(15) do |bm|
|
44
|
+
bm.report("unneeded_events") { plan.unneeded_events }
|
45
|
+
bm.report("unneeded_tasks") { plan.unneeded_tasks }
|
46
|
+
bm.report("garbage_collect") { plan.garbage_collect }
|
47
|
+
end
|
48
|
+
|
data/benchmark/genom.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
TOP_SRC_DIR = File.expand_path( File.join(File.dirname(__FILE__), '..') )
|
2
|
+
$LOAD_PATH.unshift TOP_SRC_DIR
|
3
|
+
$LOAD_PATH.unshift File.join(TOP_SRC_DIR, 'test')
|
4
|
+
require 'test_config'
|
5
|
+
require 'genom/runner'
|
6
|
+
require 'roby/adapters/genom'
|
7
|
+
|
8
|
+
include Roby
|
9
|
+
|
10
|
+
GC.disable
|
11
|
+
::Genom::Runner.h2 do |env|
|
12
|
+
::Genom.connect do
|
13
|
+
Roby::Genom::GenomModule('mockup')
|
14
|
+
env.start_modules('mockup')
|
15
|
+
|
16
|
+
task = Roby::Genom::Mockup.start
|
17
|
+
task.start!
|
18
|
+
|
19
|
+
while !task.running?
|
20
|
+
$stderr.puts "waiting for task to start"
|
21
|
+
Roby.process_events
|
22
|
+
end
|
23
|
+
|
24
|
+
task.activity.abort.wait
|
25
|
+
while !task.finished?
|
26
|
+
$stderr.puts "waiting for task to end"
|
27
|
+
Roby.process_events
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
@@ -0,0 +1,62 @@
|
|
1
|
+
TOP_SRC_DIR = File.expand_path( File.join(File.dirname(__FILE__), '..') )
|
2
|
+
$LOAD_PATH.unshift TOP_SRC_DIR
|
3
|
+
$LOAD_PATH.unshift File.join(TOP_SRC_DIR, 'test')
|
4
|
+
|
5
|
+
require 'roby'
|
6
|
+
require 'roby/transactions'
|
7
|
+
require 'utilrb/objectstats'
|
8
|
+
|
9
|
+
include Roby
|
10
|
+
|
11
|
+
TASK_COUNT = 10
|
12
|
+
RELATION_COUNT = 10
|
13
|
+
def display_object_count
|
14
|
+
count = ObjectStats.count_by_class.
|
15
|
+
find_all { |k, o| k.name =~ /Roby/ }.
|
16
|
+
sort_by { |k, o| k.name }.
|
17
|
+
map { |k, o| "#{k} #{o}" }
|
18
|
+
|
19
|
+
puts " #{count.join("\n ")}"
|
20
|
+
end
|
21
|
+
|
22
|
+
|
23
|
+
|
24
|
+
def build_and_commit
|
25
|
+
plan = Plan.new
|
26
|
+
|
27
|
+
BenchmarkAllocation.bmbm(7) do |x|
|
28
|
+
trsc = Transaction.new(plan)
|
29
|
+
plan_tasks, trsc_tasks = nil
|
30
|
+
x.report("alloc") do
|
31
|
+
trsc_tasks = (1..TASK_COUNT).map { trsc.discover(t = Task.new); t }
|
32
|
+
plan_tasks = (1..TASK_COUNT).map { plan.discover(t = Task.new); trsc[t] }
|
33
|
+
end
|
34
|
+
|
35
|
+
# Add random relations
|
36
|
+
arrays = [plan_tasks, trsc_tasks]
|
37
|
+
relation_count = [0, 0]
|
38
|
+
|
39
|
+
from_origin, to_origin = (1..2).map { rand(2) }
|
40
|
+
x.report("relations") do
|
41
|
+
RELATION_COUNT.times do
|
42
|
+
from = arrays[from_origin][rand(TASK_COUNT)]
|
43
|
+
to = arrays[to_origin][rand(TASK_COUNT)]
|
44
|
+
relation_count[from_origin] += 1
|
45
|
+
relation_count[to_origin] += 1
|
46
|
+
begin
|
47
|
+
from.realized_by to
|
48
|
+
rescue CycleFoundError
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
x.report("commit") do
|
54
|
+
trsc.commit_transaction
|
55
|
+
end
|
56
|
+
x.report("clear") do
|
57
|
+
plan.clear
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
build_and_commit
|
62
|
+
|