File tree Expand file tree Collapse file tree 1 file changed +38
-0
lines changed
language-adaptors/rxjava-jruby/src/spec/ruby/rx/lang/jruby Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Original file line number Diff line number Diff line change
1
+ # Current execution times:
2
+ # Without rxjava-jruby: 3.31s
3
+ # With rxjava-jruby: 2.18s
4
+
5
+ require 'optparse'
6
+
7
+ options = { }
8
+ OptionParser . new do |opts |
9
+ opts . banner = "Usage: jruby --profile.api performance.rb [options]"
10
+
11
+ opts . on ( "-c" , "--core CORE-PATH" , "Path to the rxjava-core.jar" ) { |core | options [ :core ] = core }
12
+ opts . on ( "-j" , "--jruby [JRUBY-PATH]" , "Path to the rxjava-jruby.jar (optional)" ) { |jruby | options [ :jruby ] = jruby }
13
+ end . parse!
14
+
15
+ require options [ :core ]
16
+
17
+ if options [ :jruby ]
18
+ require options [ :jruby ]
19
+ require 'rx/lang/jruby/interop'
20
+ end
21
+
22
+ require 'jruby/profiler'
23
+
24
+ profile_data = JRuby ::Profiler . profile do
25
+ 10000 . times do
26
+ o = Java ::Rx ::Observable . create do |observer |
27
+ observer . onNext ( "one" )
28
+ observer . onNext ( "two" )
29
+ observer . onNext ( "three" )
30
+ observer . onCompleted
31
+ Java ::RxSubscriptions ::Subscription . empty
32
+ end
33
+ o . map { |n | n * 2 } . subscribe { |n | n }
34
+ end
35
+ end
36
+
37
+ profile_printer = JRuby ::Profiler ::FlatProfilePrinter . new ( profile_data )
38
+ profile_printer . printProfile ( STDOUT )
You can’t perform that action at this time.
0 commit comments