@@ -189,17 +189,30 @@ improve performance by executing multiple tasks concurrently. In
189189this case, it makes multiple HTTP requests to an API endpoint using
190190a thread pool of persistent connections.
191191
192+ Note: ` gem install connection_pool ` to run this example.
193+
192194** Benefits:**
193195
194- * Improved performance by avoiding the overhead of creating and
195- destroying connections for each request.
196- * Efficient use of resources by sharing connections among multiple
197- threads.
198- * Concurrency and parallelism, allowing multiple requests to be
199- processed simultaneously.
196+ * Improved performance by avoiding the overhead of creating and destroying connections for each request.
197+ * Efficient use of resources by sharing connections among multiple threads.
198+ * Concurrency and parallelism, allowing multiple requests to be processed simultaneously.
199+
200+ benchmark: (demo/demo_thread_pool.rb)
201+
202+ ** Benchmark Ruby 3.4.8 vs Ruby 4.0.0 **
200203
201204benchmark: (demo/demo_thread_pool.rb)
202205
206+ | ruby | runtime (s) | thread | time/thread (s) |
207+ | ------| ------------:| -------:| ----------------:|
208+ | 3.4.8 | 0.018644 | 4 | 0.004661 |
209+ | 4.0.0 | 0.017302 | 4 | 0.004326 |
210+
211+ Ruby 4.0.0 shows a slight improvement over Ruby 3.4.8, but the difference is not significant using thread.
212+ Ractor could be considered for a more efficient use of resources but it's still in the experimental stage.
213+
214+ Note: in this benchmark, ` thread == HTTP connections ` .
215+
203216### Real world search without persistency
204217
205218``` ruby
0 commit comments