Skip to content

Commit 72bae11

Browse files
committed
Decouple performance info from README
1 parent 0ea7f42 commit 72bae11

3 files changed

Lines changed: 60 additions & 93 deletions

File tree

‎BENCHMARKS.md‎

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
## Performance Comparison
2+
3+
### Ruby 4.0.0 vs 3.4.4 vs Ruby 2.7.8 Performance
4+
5+
| Metric | Ruby 2.7.8 | Ruby 3.4.4 | Ruby 4.0.0 | Improvement (3.4.4 vs 2.7.8) | Improvement (4.0.0 vs 3.4.4) |
6+
|--------|------------|------------|------------|------------------------------|------------------------------|
7+
| **SerpApi Non-Persistent** | 100.93 req/s | 114.97 req/s | 120.09 req/s | **+13.9%** | **+4.5%** |
8+
| **SerpApi Persistent** | 226.82 req/s | 255.07 req/s | 296.05 req/s | **+12.4%** | **+16.1%** |
9+
| **HTTP.rb Non-Persistent** | 270.62 req/s | 294.01 req/s | 319.81 req/s | **+8.6%** | **+8.8%** |
10+
| **HTTP.rb Persistent** | 347.04 req/s | 570.95 req/s | 456.93 req/s | **+64.5%** | **-20.0%** |
11+
12+
#### Thread Pool Demo
13+
14+
Here's a benchmark of `demo/demo_thread_pool.rb`:
15+
16+
** Benchmark Ruby 3.4.8 vs Ruby 4.0.0 **
17+
18+
benchmark: (demo/demo_thread_pool.rb)
19+
20+
| ruby | runtime (s) | thread | time/thread (s) |
21+
|------|------------:|-------:|----------------:|
22+
| 3.4.8 | 0.018644 | 4 | 0.004661 |
23+
| 4.0.0 | 0.017302 | 4 | 0.004326 |
24+
25+
Ruby 4.0.0 shows a slight improvement over Ruby 3.4.8, but the difference is not significant using thread.
26+
Ractor could be considered for a more efficient use of resources but it's still in the experimental stage.
27+
28+
Note: in this benchmark, `thread == HTTP connections`.
29+
30+
### Key Takeaways
31+
32+
1. **Upgrade to Ruby 3.4.4**: Clear performance benefits across all scenarios
33+
2. **Use Persistent Connections**: 2x+ performance improvement in most cases
34+
3. **HTTP.rb Performance**: Particularly benefits from Ruby 3.4.4 with persistent connections
35+
4. **SerpApi Optimization**: Shows consistent ~2.2x improvement with persistent connections regardless of Ruby version
36+
5. **Ruby 4.0.0 Performance**: Shows mixed results with some regressions compared to 3.4.4, particularly for HTTP.rb persistent connections. Ruby 4.0.0 was just released for Christmas 2025, and HTTP.rb has not been optimized for it yet.
37+
38+
The older library (google-search-results-ruby) was performing at 55 req/s on Ruby 2.7.8, which is 2x slower than the current version (serpapi-ruby) on Ruby 3.4.4 or 4.0.0.
39+
40+
**Context** This benchmark was performed on warmup search results using a MacBook Pro 2025 connected via Wi-Fi 6.0 home network on AT&T fiber from Austin, TX (no network optimization).

‎README.md‎

Lines changed: 10 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,23 @@ Query a vast range of data at scale, including web search results, flight schedu
1616

1717
## Installation
1818

19-
Ruby 2.7 and higher are supported. To achieve an optimal performance, the latest version is recommended. Check 2.7.8 vs 3.4.4 [performance comparison](#Performance-Comparison).
19+
### RubyGems
2020

21-
Other versions, such as Ruby 1.9, Ruby 2.x, and JRuby, are compatible with [legacy SerpApi library](https://github.com/serpapi/google-search-results-ruby), which is still supported. To upgrade to the latest library, check our [migration guide](#Migration-quick-guide).
21+
```bash
22+
$ gem install serpapi
23+
```
24+
25+
[RubyGems page](https://rubygems.org/gems/serpapi/)
26+
27+
Ruby 2.7 and higher are supported. Other versions, such as Ruby 1.9, Ruby 2.x, and JRuby, are compatible with [legacy SerpApi library](https://github.com/serpapi/google-search-results-ruby), which is still supported. To upgrade to the latest library, check our [migration guide](#Migration-quick-guide).
2228

2329
### Bundler
30+
2431
```ruby
32+
# Gemfile
2533
gem 'serpapi', '~> 1.0', '>= 1.0.3'
2634
```
2735

28-
### Gem
29-
```bash
30-
$ gem install serpapi
31-
```
32-
33-
[Ruby Gem page](https://rubygems.org/gems/serpapi/)
34-
3536
## Simple Usage
3637

3738
```ruby
@@ -197,22 +198,6 @@ Note: `gem install connection_pool` to run this example.
197198
* Efficient use of resources by sharing connections among multiple threads.
198199
* Concurrency and parallelism, allowing multiple requests to be processed simultaneously.
199200

200-
benchmark: (demo/demo_thread_pool.rb)
201-
202-
** Benchmark Ruby 3.4.8 vs Ruby 4.0.0 **
203-
204-
benchmark: (demo/demo_thread_pool.rb)
205-
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-
216201
### Real world search without persistency
217202

218203
```ruby
@@ -1009,28 +994,6 @@ pp results[:organic_results]
1009994
* source code: [spec/serpapi/client/example/example_search_yelp_spec.rb](https://github.com/serpapi/serpapi-ruby/blob/master/spec/serpapi/client/example/example_search_yelp_spec.rb)
1010995
see: [https://serpapi.com/yelp-search-api](https://serpapi.com/yelp-search-api)
1011996

1012-
## Performance Comparison
1013-
1014-
### Ruby 4.0.0 vs 3.4.4 vs Ruby 2.7.8 Performance
1015-
1016-
| Metric | Ruby 2.7.8 | Ruby 3.4.4 | Ruby 4.0.0 | Improvement (3.4.4 vs 2.7.8) | Improvement (4.0.0 vs 3.4.4) |
1017-
|--------|------------|------------|------------|------------------------------|------------------------------|
1018-
| **SerpApi Non-Persistent** | 100.93 req/s | 114.97 req/s | 120.09 req/s | **+13.9%** | **+4.5%** |
1019-
| **SerpApi Persistent** | 226.82 req/s | 255.07 req/s | 296.05 req/s | **+12.4%** | **+16.1%** |
1020-
| **HTTP.rb Non-Persistent** | 270.62 req/s | 294.01 req/s | 319.81 req/s | **+8.6%** | **+8.8%** |
1021-
| **HTTP.rb Persistent** | 347.04 req/s | 570.95 req/s | 456.93 req/s | **+64.5%** | **-20.0%** |
1022-
1023-
### Key Takeaways
1024-
1. **Upgrade to Ruby 3.4.4**: Clear performance benefits across all scenarios
1025-
2. **Use Persistent Connections**: 2x+ performance improvement in most cases
1026-
3. **HTTP.rb Performance**: Particularly benefits from Ruby 3.4.4 with persistent connections
1027-
4. **SerpApi Optimization**: Shows consistent ~2.2x improvement with persistent connections regardless of Ruby version
1028-
5. **Ruby 4.0.0 Performance**: Shows mixed results with some regressions compared to 3.4.4, particularly for HTTP.rb persistent connections. Ruby 4.0.0 was just released for Christmas 2025, and HTTP.rb has not been optimized for it yet.
1029-
1030-
The older library (google-search-results-ruby) was performing at 55 req/s on Ruby 2.7.8, which is 2x slower than the current version (serpapi-ruby) on Ruby 3.4.4 or 4.0.0.
1031-
1032-
**Context** This benchmark was performed on warmup search results using a MacBook Pro 2025 connected via Wi-Fi 6.0 home network on AT&T fiber from Austin, TX (no network optimization).
1033-
1034997
## Migration quick guide
1035998

1036999
If you were already using [google-search-results-ruby gem](https://github.com/serpapi/google-search-results-ruby), here are the changes.

‎README.md.erb‎

Lines changed: 10 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -36,22 +36,23 @@ Query a vast range of data at scale, including web search results, flight schedu
3636

3737
## Installation
3838

39-
Ruby 2.7 and higher are supported. To achieve an optimal performance, the latest version is recommended. Check 2.7.8 vs 3.4.4 [performance comparison](#Performance-Comparison).
39+
### RubyGems
4040

41-
Other versions, such as Ruby 1.9, Ruby 2.x, and JRuby, are compatible with [legacy SerpApi library](https://github.com/serpapi/google-search-results-ruby), which is still supported. To upgrade to the latest library, check our [migration guide](#Migration-quick-guide).
41+
```bash
42+
$ gem install serpapi
43+
```
44+
45+
[RubyGems page](https://rubygems.org/gems/serpapi/)
46+
47+
Ruby 2.7 and higher are supported. Other versions, such as Ruby 1.9, Ruby 2.x, and JRuby, are compatible with [legacy SerpApi library](https://github.com/serpapi/google-search-results-ruby), which is still supported. To upgrade to the latest library, check our [migration guide](#Migration-quick-guide).
4248

4349
### Bundler
50+
4451
```ruby
52+
# Gemfile
4553
gem 'serpapi', '~> 1.0', '>= 1.0.3'
4654
```
4755

48-
### Gem
49-
```bash
50-
$ gem install serpapi
51-
```
52-
53-
[Ruby Gem page](https://rubygems.org/gems/serpapi/)
54-
5556
## Simple Usage
5657

5758
```ruby
@@ -217,22 +218,6 @@ Note: `gem install connection_pool` to run this example.
217218
* Efficient use of resources by sharing connections among multiple threads.
218219
* Concurrency and parallelism, allowing multiple requests to be processed simultaneously.
219220

220-
benchmark: (demo/demo_thread_pool.rb)
221-
222-
** Benchmark Ruby 3.4.8 vs Ruby 4.0.0 **
223-
224-
benchmark: (demo/demo_thread_pool.rb)
225-
226-
| ruby | runtime (s) | thread | time/thread (s) |
227-
|------|------------:|-------:|----------------:|
228-
| 3.4.8 | 0.018644 | 4 | 0.004661 |
229-
| 4.0.0 | 0.017302 | 4 | 0.004326 |
230-
231-
Ruby 4.0.0 shows a slight improvement over Ruby 3.4.8, but the difference is not significant using thread.
232-
Ractor could be considered for a more efficient use of resources but it's still in the experimental stage.
233-
234-
Note: in this benchmark, `thread == HTTP connections`.
235-
236221
### Real world search without persistency
237222

238223
```ruby
@@ -490,27 +475,6 @@ see: [https://serpapi.com/yandex-search-api](https://serpapi.com/yandex-search-a
490475
<%= snippet('ruby', 'spec/serpapi/client/example/example_search_yelp_spec.rb') %>
491476
see: [https://serpapi.com/yelp-search-api](https://serpapi.com/yelp-search-api)
492477

493-
## Performance Comparison
494-
495-
### Ruby 4.0.0 vs 3.4.4 vs Ruby 2.7.8 Performance
496-
497-
| Metric | Ruby 2.7.8 | Ruby 3.4.4 | Ruby 4.0.0 | Improvement (3.4.4 vs 2.7.8) | Improvement (4.0.0 vs 3.4.4) |
498-
|--------|------------|------------|------------|------------------------------|------------------------------|
499-
| **SerpApi Non-Persistent** | 100.93 req/s | 114.97 req/s | 120.09 req/s | **+13.9%** | **+4.5%** |
500-
| **SerpApi Persistent** | 226.82 req/s | 255.07 req/s | 296.05 req/s | **+12.4%** | **+16.1%** |
501-
| **HTTP.rb Non-Persistent** | 270.62 req/s | 294.01 req/s | 319.81 req/s | **+8.6%** | **+8.8%** |
502-
| **HTTP.rb Persistent** | 347.04 req/s | 570.95 req/s | 456.93 req/s | **+64.5%** | **-20.0%** |
503-
504-
### Key Takeaways
505-
1. **Upgrade to Ruby 3.4.4**: Clear performance benefits across all scenarios
506-
2. **Use Persistent Connections**: 2x+ performance improvement in most cases
507-
3. **HTTP.rb Performance**: Particularly benefits from Ruby 3.4.4 with persistent connections
508-
4. **SerpApi Optimization**: Shows consistent ~2.2x improvement with persistent connections regardless of Ruby version
509-
5. **Ruby 4.0.0 Performance**: Shows mixed results with some regressions compared to 3.4.4, particularly for HTTP.rb persistent connections. Ruby 4.0.0 was just released for Christmas 2025, and HTTP.rb has not been optimized for it yet.
510-
511-
The older library (google-search-results-ruby) was performing at 55 req/s on Ruby 2.7.8, which is 2x slower than the current version (serpapi-ruby) on Ruby 3.4.4 or 4.0.0.
512-
513-
**Context** This benchmark was performed on warmup search results using a MacBook Pro 2025 connected via Wi-Fi 6.0 home network on AT&T fiber from Austin, TX (no network optimization).
514478

515479
## Migration quick guide
516480

0 commit comments

Comments
 (0)