opal 1.6.1 → 1.7.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (212) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/build.yml +17 -0
  3. data/Gemfile +1 -0
  4. data/HACKING.md +47 -26
  5. data/UNRELEASED.md +28 -0
  6. data/benchmark/benchmarks +415 -103
  7. data/benchmark/bm_call_overhead.yml +28 -0
  8. data/benchmark/run.rb +61 -40
  9. data/docs/cdp_common.json +3364 -0
  10. data/docs/cdp_common.md +18 -0
  11. data/docs/{headless_chrome.md → headless_browsers.md} +31 -12
  12. data/lib/opal/ast/builder.rb +1 -1
  13. data/lib/opal/builder.rb +6 -1
  14. data/lib/opal/builder_processors.rb +5 -3
  15. data/lib/opal/cache.rb +1 -7
  16. data/lib/opal/cli_options.rb +72 -58
  17. data/lib/opal/cli_runners/chrome.rb +47 -9
  18. data/lib/opal/cli_runners/chrome_cdp_interface.rb +238 -112
  19. data/lib/opal/cli_runners/compiler.rb +146 -13
  20. data/lib/opal/cli_runners/deno.rb +32 -0
  21. data/lib/opal/cli_runners/firefox.rb +350 -0
  22. data/lib/opal/cli_runners/firefox_cdp_interface.rb +212 -0
  23. data/lib/opal/cli_runners/node_modules/.bin/chrome-remote-interface.cmd +17 -0
  24. data/lib/opal/cli_runners/node_modules/.bin/chrome-remote-interface.ps1 +28 -0
  25. data/lib/opal/cli_runners/node_modules/.package-lock.json +41 -0
  26. data/lib/opal/cli_runners/node_modules/chrome-remote-interface/LICENSE +1 -1
  27. data/lib/opal/cli_runners/node_modules/chrome-remote-interface/README.md +322 -182
  28. data/lib/opal/cli_runners/node_modules/chrome-remote-interface/bin/client.js +99 -114
  29. data/lib/opal/cli_runners/node_modules/chrome-remote-interface/chrome-remote-interface.js +1 -11
  30. data/lib/opal/cli_runners/node_modules/chrome-remote-interface/index.js +16 -11
  31. data/lib/opal/cli_runners/node_modules/chrome-remote-interface/lib/api.js +41 -33
  32. data/lib/opal/cli_runners/node_modules/chrome-remote-interface/lib/chrome.js +224 -214
  33. data/lib/opal/cli_runners/node_modules/chrome-remote-interface/lib/devtools.js +71 -191
  34. data/lib/opal/cli_runners/node_modules/chrome-remote-interface/lib/external-request.js +26 -6
  35. data/lib/opal/cli_runners/node_modules/chrome-remote-interface/lib/protocol.json +20788 -9049
  36. data/lib/opal/cli_runners/node_modules/chrome-remote-interface/lib/websocket-wrapper.js +10 -3
  37. data/lib/opal/cli_runners/node_modules/chrome-remote-interface/package.json +59 -123
  38. data/lib/opal/cli_runners/node_modules/chrome-remote-interface/webpack.config.js +25 -32
  39. data/lib/opal/cli_runners/node_modules/commander/History.md +298 -0
  40. data/lib/opal/cli_runners/node_modules/commander/LICENSE +22 -0
  41. data/lib/opal/cli_runners/node_modules/commander/Readme.md +217 -61
  42. data/lib/opal/cli_runners/node_modules/commander/index.js +431 -145
  43. data/lib/opal/cli_runners/node_modules/commander/package.json +16 -79
  44. data/lib/opal/cli_runners/node_modules/ws/README.md +334 -98
  45. data/lib/opal/cli_runners/node_modules/ws/browser.js +8 -0
  46. data/lib/opal/cli_runners/node_modules/ws/index.js +5 -10
  47. data/lib/opal/cli_runners/node_modules/ws/lib/buffer-util.js +129 -0
  48. data/lib/opal/cli_runners/node_modules/ws/lib/constants.js +10 -0
  49. data/lib/opal/cli_runners/node_modules/ws/lib/event-target.js +184 -0
  50. data/lib/opal/cli_runners/node_modules/ws/lib/extension.js +223 -0
  51. data/lib/opal/cli_runners/node_modules/ws/lib/limiter.js +55 -0
  52. data/lib/opal/cli_runners/node_modules/ws/lib/permessage-deflate.js +518 -0
  53. data/lib/opal/cli_runners/node_modules/ws/lib/receiver.js +607 -0
  54. data/lib/opal/cli_runners/node_modules/ws/lib/sender.js +409 -0
  55. data/lib/opal/cli_runners/node_modules/ws/lib/stream.js +180 -0
  56. data/lib/opal/cli_runners/node_modules/ws/lib/validation.js +104 -0
  57. data/lib/opal/cli_runners/node_modules/ws/lib/websocket-server.js +447 -0
  58. data/lib/opal/cli_runners/node_modules/ws/lib/websocket.js +1195 -0
  59. data/lib/opal/cli_runners/node_modules/ws/package.json +40 -106
  60. data/lib/opal/cli_runners/package-lock.json +62 -0
  61. data/lib/opal/cli_runners/package.json +1 -1
  62. data/lib/opal/cli_runners.rb +26 -4
  63. data/lib/opal/nodes/args/prepare_post_args.rb +2 -2
  64. data/lib/opal/nodes/def.rb +8 -8
  65. data/lib/opal/nodes/iter.rb +12 -12
  66. data/lib/opal/nodes/logic.rb +1 -1
  67. data/lib/opal/nodes/masgn.rb +2 -2
  68. data/lib/opal/parser/with_ruby_lexer.rb +1 -1
  69. data/lib/opal/paths.rb +14 -0
  70. data/lib/opal/rewriter.rb +2 -0
  71. data/lib/opal/rewriters/forward_args.rb +52 -4
  72. data/lib/opal/rewriters/targeted_patches.rb +94 -0
  73. data/lib/opal/version.rb +1 -1
  74. data/opal/corelib/basic_object.rb +1 -1
  75. data/opal/corelib/boolean.rb +2 -2
  76. data/opal/corelib/class.rb +11 -0
  77. data/opal/corelib/constants.rb +3 -3
  78. data/opal/corelib/enumerable.rb +4 -0
  79. data/opal/corelib/enumerator.rb +1 -1
  80. data/opal/corelib/hash.rb +2 -2
  81. data/opal/corelib/helpers.rb +1 -1
  82. data/opal/corelib/kernel.rb +3 -3
  83. data/opal/corelib/method.rb +1 -1
  84. data/opal/corelib/module.rb +29 -8
  85. data/opal/corelib/proc.rb +7 -5
  86. data/opal/corelib/runtime.js +141 -78
  87. data/opal/corelib/set.rb +252 -0
  88. data/opal/corelib/string.rb +2 -1
  89. data/opal/corelib/time.rb +2 -2
  90. data/opal/opal.rb +1 -0
  91. data/opal.gemspec +1 -0
  92. data/spec/filters/bugs/array.rb +22 -13
  93. data/spec/filters/bugs/base64.rb +5 -5
  94. data/spec/filters/bugs/basicobject.rb +16 -8
  95. data/spec/filters/bugs/bigdecimal.rb +161 -160
  96. data/spec/filters/bugs/binding.rb +10 -10
  97. data/spec/filters/bugs/class.rb +8 -8
  98. data/spec/filters/bugs/complex.rb +2 -1
  99. data/spec/filters/bugs/date.rb +79 -81
  100. data/spec/filters/bugs/datetime.rb +29 -29
  101. data/spec/filters/bugs/delegate.rb +1 -3
  102. data/spec/filters/bugs/encoding.rb +69 -69
  103. data/spec/filters/bugs/enumerable.rb +22 -20
  104. data/spec/filters/bugs/enumerator.rb +88 -85
  105. data/spec/filters/bugs/exception.rb +46 -40
  106. data/spec/filters/bugs/file.rb +32 -32
  107. data/spec/filters/bugs/float.rb +26 -21
  108. data/spec/filters/bugs/freeze.rb +88 -0
  109. data/spec/filters/bugs/hash.rb +39 -38
  110. data/spec/filters/bugs/integer.rb +57 -44
  111. data/spec/filters/bugs/io.rb +1 -1
  112. data/spec/filters/bugs/kernel.rb +349 -269
  113. data/spec/filters/bugs/language.rb +220 -188
  114. data/spec/filters/bugs/main.rb +5 -3
  115. data/spec/filters/bugs/marshal.rb +38 -38
  116. data/spec/filters/bugs/math.rb +2 -1
  117. data/spec/filters/bugs/method.rb +73 -62
  118. data/spec/filters/bugs/module.rb +163 -143
  119. data/spec/filters/bugs/numeric.rb +6 -6
  120. data/spec/filters/bugs/objectspace.rb +16 -16
  121. data/spec/filters/bugs/openstruct.rb +1 -1
  122. data/spec/filters/bugs/pack_unpack.rb +51 -51
  123. data/spec/filters/bugs/pathname.rb +7 -7
  124. data/spec/filters/bugs/proc.rb +63 -63
  125. data/spec/filters/bugs/random.rb +7 -6
  126. data/spec/filters/bugs/range.rb +12 -9
  127. data/spec/filters/bugs/rational.rb +8 -7
  128. data/spec/filters/bugs/regexp.rb +49 -48
  129. data/spec/filters/bugs/ruby-32.rb +56 -0
  130. data/spec/filters/bugs/set.rb +30 -30
  131. data/spec/filters/bugs/singleton.rb +4 -4
  132. data/spec/filters/bugs/string.rb +187 -99
  133. data/spec/filters/bugs/stringio.rb +7 -0
  134. data/spec/filters/bugs/stringscanner.rb +68 -68
  135. data/spec/filters/bugs/struct.rb +11 -9
  136. data/spec/filters/bugs/symbol.rb +1 -1
  137. data/spec/filters/bugs/time.rb +78 -63
  138. data/spec/filters/bugs/trace_point.rb +4 -4
  139. data/spec/filters/bugs/unboundmethod.rb +32 -17
  140. data/spec/filters/bugs/warnings.rb +8 -12
  141. data/spec/filters/unsupported/array.rb +24 -107
  142. data/spec/filters/unsupported/basicobject.rb +12 -12
  143. data/spec/filters/unsupported/bignum.rb +27 -52
  144. data/spec/filters/unsupported/class.rb +1 -2
  145. data/spec/filters/unsupported/delegator.rb +3 -3
  146. data/spec/filters/unsupported/enumerable.rb +2 -9
  147. data/spec/filters/unsupported/enumerator.rb +2 -11
  148. data/spec/filters/unsupported/file.rb +1 -1
  149. data/spec/filters/unsupported/float.rb +28 -47
  150. data/spec/filters/unsupported/hash.rb +8 -14
  151. data/spec/filters/unsupported/integer.rb +75 -91
  152. data/spec/filters/unsupported/kernel.rb +17 -35
  153. data/spec/filters/unsupported/language.rb +11 -19
  154. data/spec/filters/unsupported/marshal.rb +22 -41
  155. data/spec/filters/unsupported/matchdata.rb +28 -52
  156. data/spec/filters/unsupported/math.rb +1 -1
  157. data/spec/filters/unsupported/privacy.rb +229 -285
  158. data/spec/filters/unsupported/range.rb +1 -5
  159. data/spec/filters/unsupported/regexp.rb +40 -66
  160. data/spec/filters/unsupported/set.rb +2 -2
  161. data/spec/filters/unsupported/singleton.rb +4 -4
  162. data/spec/filters/unsupported/string.rb +305 -508
  163. data/spec/filters/unsupported/struct.rb +3 -4
  164. data/spec/filters/unsupported/symbol.rb +15 -18
  165. data/spec/filters/unsupported/thread.rb +1 -7
  166. data/spec/filters/unsupported/time.rb +159 -202
  167. data/spec/filters/unsupported/usage_of_files.rb +170 -259
  168. data/spec/lib/builder_spec.rb +4 -4
  169. data/spec/lib/rewriters/forward_args_spec.rb +32 -12
  170. data/spec/mspec-opal/runner.rb +2 -0
  171. data/spec/ruby_specs +4 -0
  172. data/stdlib/deno/base.rb +28 -0
  173. data/stdlib/deno/file.rb +340 -0
  174. data/stdlib/{headless_chrome.rb → headless_browser/base.rb} +1 -1
  175. data/stdlib/headless_browser/file.rb +15 -0
  176. data/stdlib/headless_browser.rb +4 -0
  177. data/stdlib/native.rb +1 -1
  178. data/stdlib/nodejs/file.rb +5 -0
  179. data/stdlib/opal/platform.rb +8 -6
  180. data/stdlib/opal-platform.rb +14 -8
  181. data/stdlib/set.rb +1 -258
  182. data/tasks/benchmarking.rake +62 -19
  183. data/tasks/performance.rake +1 -1
  184. data/tasks/testing.rake +5 -3
  185. data/test/nodejs/test_file.rb +29 -10
  186. data/test/opal/http_server.rb +28 -11
  187. data/test/opal/unsupported_and_bugs.rb +2 -1
  188. metadata +91 -52
  189. data/lib/opal/cli_runners/node_modules/ultron/LICENSE +0 -22
  190. data/lib/opal/cli_runners/node_modules/ultron/index.js +0 -138
  191. data/lib/opal/cli_runners/node_modules/ultron/package.json +0 -112
  192. data/lib/opal/cli_runners/node_modules/ws/SECURITY.md +0 -33
  193. data/lib/opal/cli_runners/node_modules/ws/lib/BufferUtil.fallback.js +0 -56
  194. data/lib/opal/cli_runners/node_modules/ws/lib/BufferUtil.js +0 -15
  195. data/lib/opal/cli_runners/node_modules/ws/lib/ErrorCodes.js +0 -28
  196. data/lib/opal/cli_runners/node_modules/ws/lib/EventTarget.js +0 -158
  197. data/lib/opal/cli_runners/node_modules/ws/lib/Extensions.js +0 -69
  198. data/lib/opal/cli_runners/node_modules/ws/lib/PerMessageDeflate.js +0 -339
  199. data/lib/opal/cli_runners/node_modules/ws/lib/Receiver.js +0 -520
  200. data/lib/opal/cli_runners/node_modules/ws/lib/Sender.js +0 -438
  201. data/lib/opal/cli_runners/node_modules/ws/lib/Validation.fallback.js +0 -9
  202. data/lib/opal/cli_runners/node_modules/ws/lib/Validation.js +0 -17
  203. data/lib/opal/cli_runners/node_modules/ws/lib/WebSocket.js +0 -705
  204. data/lib/opal/cli_runners/node_modules/ws/lib/WebSocketServer.js +0 -336
  205. data/spec/filters/bugs/boolean.rb +0 -3
  206. data/spec/filters/bugs/matrix.rb +0 -3
  207. data/spec/filters/unsupported/fixnum.rb +0 -15
  208. data/spec/filters/unsupported/freeze.rb +0 -102
  209. data/spec/filters/unsupported/pathname.rb +0 -4
  210. data/spec/filters/unsupported/proc.rb +0 -4
  211. data/spec/filters/unsupported/random.rb +0 -5
  212. data/spec/filters/unsupported/taint.rb +0 -162
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1c701c29f145e065c4abcaf8ab8884b6c72bc2d4b7f1a4c20dd293e05b4ab824
4
- data.tar.gz: c42cd06d101ed3cab5b7c116f87bb8de200b1eaacee107228f2cad20a6bde94d
3
+ metadata.gz: 38a2d4a4ed5e087f1bed29102d84f675f8afe1db295464f44b1d4aee52e6c633
4
+ data.tar.gz: 290899e91ac1683024cf394ea8b66d64f4df70df7a1233723a9aac88002e6b73
5
5
  SHA512:
6
- metadata.gz: cb68516917eccc5b981fed3f71b31ddd96378a0bc5d7a56d3d8d0728b80dee4dbe0fb7f00b998e4c85a87cd8a6925268046b817f9741ef015ef17f8d7e18f922
7
- data.tar.gz: f296bfaa2d953d3b966bda9b6ae3ebff0b43d711c60a4816810adcc091afcec09608a3c7895b156b8267bfac99dd67e93f9868100356939e92bbd9609a715a60
6
+ metadata.gz: b13492436e25b705e65cde1a672f24cb668c9743992cc7d17f40d248a72a55cc9a8d9ade0a785d236972278217f89f54eb6362ca87411a026a4c41fd69c72c9b
7
+ data.tar.gz: e7944265ce2f63fd094a624ec42738da5f098e55330da3ea4184b225411dc4c28fb00b792023b578edad3c45efc6e170b920330c7fed87a77bda53dd32219b7d
@@ -24,6 +24,12 @@ jobs:
24
24
  - name: mspec-chrome
25
25
  ruby: '3.0'
26
26
  command: bin/rake mspec_chrome
27
+ - name: minitest-firefox
28
+ env:
29
+ # when changing version, also change it below
30
+ MOZILLA_FIREFOX_BINARY: '/opt/hostedtoolcache/firefox/106.0.4/x64/firefox'
31
+ ruby: '3.0'
32
+ command: xvfb-run bin/rake minitest_firefox
27
33
  - name: minitest
28
34
  ruby: '3.0'
29
35
  command: bin/rake minitest
@@ -53,6 +59,13 @@ jobs:
53
59
  command: bundle exec rake mspec_chrome
54
60
  ruby: '3.0'
55
61
  os: windows-latest
62
+ - name: windows-minitest-firefox
63
+ env:
64
+ # when changing version, also change it below and above
65
+ MOZILLA_FIREFOX_BINARY: 'C:/Program Files/Firefox_106.0.4/firefox.exe'
66
+ ruby: '3.0'
67
+ command: bundle exec rake minitest_firefox
68
+ os: windows-latest
56
69
  - name: windows-minitest
57
70
  command: bundle exec rake minitest
58
71
  ruby: '3.0'
@@ -81,6 +94,10 @@ jobs:
81
94
  runs-on: ${{ matrix.combo.os || 'ubuntu-latest' }}
82
95
  continue-on-error: ${{ matrix.combo.permissive || false }}
83
96
  steps:
97
+ - uses: browser-actions/setup-firefox@latest
98
+ with:
99
+ # when changing version, also change it above
100
+ firefox-version: '106.0.4'
84
101
  - uses: actions/checkout@v2
85
102
  with:
86
103
  fetch-depth: ${{ fromJSON(matrix.combo.fetchdepth || '1') }}
data/Gemfile CHANGED
@@ -39,6 +39,7 @@ end
39
39
  group :development do
40
40
  gem 'rb-fsevent'
41
41
  gem 'guard', require: false
42
+ gem 'listen', require: false
42
43
 
43
44
  if RUBY_PLATFORM =~ /darwin/
44
45
  gem 'terminal-notifier-guard'
data/HACKING.md CHANGED
@@ -86,26 +86,29 @@ Also there are some specs in `spec/ruby/language/while_spec.rb` that cause an in
86
86
 
87
87
  ## Benchmarking
88
88
 
89
- There are two ways to benchmark Opal's performance: one way is to write a program (or a set of programs) that takes sufficently long time to execute, then measure the execution time, and the other is to execute a specific Ruby Spec Suite example (or a set of examples) multiple times, then measure the execution time. Let's call the former "Traditional Benchmarking", and the latter "The Ruby Spec Suite Benchmarking".
89
+ Opal benchmarking uses the standard Ruby [benchmark_driver](https://github.com/benchmark-driver/), allowing for Ruby .rb and .yaml benchmarks. Examples are available in the `benchmark` directory.
90
90
 
91
- Regardless of which of the two types of benchmarking above you happen to be doing, the reporting of benchmark results works the same way: `bundle exec rake bench:report`.
92
-
93
- It's important to understand that benchmarking in Opal works on the principle of a single, shared benchmarking workspace, a *bench*, where the results of each benchmark run that you perform get automatically saved. When you do `bundle exec rake bench:report`, you get a combined report of all of the benchmark results that are currently sitting in your workspace. This means you can check out an older commit, run benchmarks, checkout a newer commit, run benchmarks, then run the report to see the results from the two commits side-by-side. After you're done, (or before starting a new benchmarking session), you can do `bundle exec rake bench:clear` to reset your workspace to a clean slate.
91
+ Benchmarking in Opal works on the principle of a single, shared benchmarking workspace, a *bench*, where the results of each benchmark run that you perform get automatically saved. When you do `bundle exec rake bench:report`, you get a combined report of all of the benchmark results that are currently sitting in your workspace. This means you can check out an older commit, run benchmarks, checkout a newer commit, run benchmarks, then run the report to see the results from the two commits side-by-side. After you're done, (or before starting a new benchmarking session), you can do `bundle exec rake bench:clear` to reset your workspace to a clean slate.
94
92
 
95
93
  You can get a list of all the available benchmarking commands by running `bundle exec rake -T | grep bench` as shown below.
96
94
 
95
+ On Windows make sure to enable the DevKit before running benchmarks: `ridk enable`.
96
+ On Linux, depending on your environment, it may be required to use `xvfb-run bundle exec ...` to make sure browser runners can run in headless mode.
97
+
97
98
  ```
98
99
  $ bundle exec rake -T | grep bench
99
100
 
100
101
  rake bench:clear # Delete all benchmark results
101
- rake bench:opal # Benchmark Opal
102
- rake bench:report # Combined report of all benchmark results
102
+ rake bench:opal_chrome # Benchmark Opal with Chrome runner
103
+ rake bench:opal_firefox # Benchmark Opal with Firefox runner
104
+ rake bench:opal_node # Benchmark Opal with Node runner
103
105
  rake bench:ruby # Benchmark Ruby
106
+ rake bench:ruby_vs_opal # Benchmark Ruby vs Opal Node
107
+ rake bench:all # Benchmark Ruby vs Opal Node vs Opal Chrome vs Opal Firefox
108
+ rake bench:report # Combined report of all benchmark results
104
109
  ```
105
110
 
106
- ### Traditional Benchmarking
107
-
108
- At the root of the opal project tree is a folder called `benchmark` that contains a file called `benchmarks`. This file lists all of the benchmarks that will be run if you do `bundle exec bench:opal` without specifying any particular benchmark file(s) as parameters to this rake task. In the example below, I pick which benchmarks to run by passing their file paths as parameters to the rake task.
111
+ At the root of the opal project tree is a folder called `benchmark` that contains a file called `benchmarks`. This file lists all of the benchmarks that will be run if you do `bundle exec bench:opal_node` without specifying any particular benchmark file(s) as parameters to this rake task. In the example below, I pick which benchmarks to run by passing their file paths as parameters to the rake task.
109
112
 
110
113
  Start with a clean slate:
111
114
 
@@ -115,43 +118,61 @@ $ bundle exec rake bench:clear
115
118
  rm tmp/bench/*
116
119
  ```
117
120
 
118
- Run two benchmark programs from the MRI benchmarking suite by passing their file paths as parameters:
121
+ Run two benchmark programs from the benchmarking suite by passing their file paths as parameters:
119
122
  (Note: passing params to Rake tasks is tricky - notice there is no space after the comma!)
120
123
 
121
124
  ```
122
- $ bundle exec rake bench:opal[test/cruby/benchmark/bm_app_answer.rb,test/cruby/benchmark/bm_app_factorial.rb]
125
+ $ bundle exec rake bench:opal_node[benchmark/bm_array_flatten.rb,benchmark/bm_array_add.rb]
126
+ bundle exec ruby benchmark/run.rb -node benchmark/bm_array_flatten.rb benchmark/bm_array_add.rb | tee tmp/bench/1_opal-node-1-5-1.txt
127
+
128
+ Benchmarking benchmark/bm_array_add.rb started at 2022-11-06 10:20:57 +0100:
129
+ Calculating -------------------------------------
130
+ bm_array_add 1.941k i/s - 1.000 times in 0.000515s (515.20μs/i)
131
+
132
+ Benchmarking benchmark/bm_array_flatten.rb started at 2022-11-06 10:21:05 +0100:
133
+ Calculating -------------------------------------
134
+ bm_array_flatten 1.037 i/s - 1.000 times in 0.964620s (964.62ms/i)
123
135
 
124
- bundle exec opal benchmark/run.rb test/cruby/benchmark/bm_app_answer.rb test/cruby/benchmark/bm_app_factorial.rb | tee tmp/bench/Opal1
125
- test/cruby/benchmark/bm_app_answer.rb 0.7710001468658447
126
- test/cruby/benchmark/bm_app_factorial.rb 0.0820000171661377
127
- ===============================================
128
- Executed 2 benchmarks in 0.8530001640319824 sec
136
+
137
+ bm_array_add 1.941k i/s - 1.000 times in 0.000515s (515.20μs/i)
138
+ bm_array_flatten 1.037 i/s - 1.000 times in 0.964620s (964.62ms/i)
129
139
  ```
130
140
 
131
141
  In this case, I want to see how Opal's results stack up against MRI's results, so I will run the same set of benchmarks for Ruby:
132
142
 
133
143
  ```
134
- $ bundle exec rake bench:ruby[test/cruby/benchmark/bm_app_answer.rb,test/cruby/benchmark/bm_app_factorial.rb]
144
+ $ bundle exec rake bench:ruby[benchmark/bm_array_flatten.rb,benchmark/bm_array_add.rb]
145
+ bundle exec ruby benchmark/run.rb -ruby benchmark/bm_array_flatten.rb benchmark/bm_array_add.rb | tee tmp/bench/2_ruby-3-2-0.txt
146
+
147
+ Benchmarking benchmark/bm_array_add.rb started at 2022-11-06 10:22:23 +0100:
148
+ Calculating -------------------------------------
149
+ bm_array_add 14.306k i/s - 1.000 times in 0.000070s (69.90μs/i)
150
+
151
+ Benchmarking benchmark/bm_array_flatten.rb started at 2022-11-06 10:22:27 +0100:
152
+ Calculating -------------------------------------
153
+ bm_array_flatten 7.347 i/s - 1.000 times in 0.136105s (136.10ms/i)
135
154
 
136
- bundle exec ruby benchmark/run.rb test/cruby/benchmark/bm_app_answer.rb test/cruby/benchmark/bm_app_factorial.rb | tee tmp/bench/Ruby1
137
- test/cruby/benchmark/bm_app_answer.rb 0.04913724200014258
138
- test/cruby/benchmark/bm_app_factorial.rb 1.3288652799965348
139
- ===============================================
140
- Executed 2 benchmarks in 1.3780025219966774 sec
155
+
156
+ bm_array_add 14.306k i/s - 1.000 times in 0.000070s (69.90μs/i)
157
+ bm_array_flatten 7.347 i/s - 1.000 times in 0.136105s (136.10ms/i)
141
158
  ```
142
159
 
143
160
  Now I'm ready to see the result of the two runs side-by-side:
144
161
 
145
162
  ```
146
163
  $ bundle exec rake bench:report
147
-
148
- Benchmark Opal1 Ruby1
149
- test/cruby/benchmark/bm_app_answer.rb 0.771 0.049
150
- test/cruby/benchmark/bm_app_factorial.rb 0.082 1.329
164
+ Base: 1_opal-node-1-5-1
165
+ Benchmark 1_opal-node-1-5-1 | 2_ruby-3-2-0 |
166
+ bm_array_flatten 1.037 i/s | +608.49% 7.347 i/s |
167
+ bm_array_add 1941.000 i/s | +637.04% 14306.000 i/s |
151
168
  ```
152
169
 
153
170
  If I were to continue running benchmarks, more columns would be added to the report. You can select which columns you want to display (and in what order) by passing their names as params to the rake task like so: `bundle exec rake bench:report[Ruby1,Opal1]`
154
171
 
172
+ Rubies, that are unknown to the Opal benchmarking harness, can be benchmarked by setting the `OPAL_BENCH_EXTRA_RUBIES` environment variable.
173
+ The full paths to the extra rubies must be specified, separated by ';', ready for benchmark_driver to be passed as option. Example:
174
+ `OPAL_BENCH_EXTRA_RUBIES="/usr/local/bin/ruby.wasm;/usr/local/bin/ruby.head"`
175
+
155
176
  ### The Ruby Spec Suite Benchmarking
156
177
 
157
178
  This type of benchmarking relies on a feature of MSpec whereby you can ask it to execute every example in a given spec multiple times. Adding `BM=<number of times>` to your regular spec suite invocation command will hook into this MSpec functionality, collect timing information, and dump the results into the benchmarking workspace, making them available for reporting. Below is an example run with a single spec and `BM` set to `100`, meaning each example in the spec would be run 100 times.
data/UNRELEASED.md CHANGED
@@ -7,3 +7,31 @@
7
7
  ### Performance
8
8
  ### Fixed
9
9
  -->
10
+
11
+ ### Added
12
+
13
+ - Update benchmarking and CLI runners, added support for Deno and Firefox (#2490, #2492, #2494, #2495, #2497, #2491, #2496)
14
+ - Ruby 3.2 support branch (#2500)
15
+ - `Set` now part of the corelib
16
+ - Anonymous rest keyword and block arguments can be passed to calls: `call(**, &)`
17
+ - `Refinement#refined_class` has been added
18
+ - `Module#refinements` has been added
19
+ - `Module#const_added` has been added
20
+ - `Proc#parameters` now accepts lambda keyword
21
+ - `Class#attached_object` has been added, inverse of `singleton_class`
22
+ - `Hash#shift` now returns `nil` instead of passing `nil` to the `default_proc`
23
+ - Added `--watch` and `--output` options to the CLI for live compilation (#2485)
24
+
25
+ ### Performance
26
+
27
+ - Replace all occurences of `'$'+name` with a cached helper, saving about 2% in performance (#2481)
28
+ - Optimize argument passing and arity checks (#2499)
29
+ - Targeted patches for Opal-Parser, saves up to 12% during compilation (#2482)
30
+
31
+ ### Internal
32
+
33
+ - MSpec & Ruby Spec update (#2486)
34
+
35
+ ### Fixed
36
+
37
+ - Remove throws from runtime (#2484)