Skip to content

Commit bcc821a

Browse files
Add benchmarks for various Addressable URI operations (#431)
* Add benchmarks for various Addressable URI operations We want to track the performance of common operations in the Addressable gem, such as parsing, normalization, component access, and modification. We heavily use the Addressable gem in our projects, so having benchmarks will help us monitor performance changes over time and ensure that updates to the gem or our codebase do not introduce regressions. * Run benchmarks 10k times, not 100 --------- Co-authored-by: Max Bernstein <[email protected]>
1 parent 25c9497 commit bcc821a

File tree

28 files changed

+358
-0
lines changed

28 files changed

+358
-0
lines changed

benchmarks.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,24 @@ shipit:
5151
#
5252
# Other Benchmarks
5353
#
54+
addressable-equality:
55+
desc: addressable URI equality comparison
56+
addressable-getters:
57+
desc: addressable URI component getters (scheme, host, port, path, query, fragment)
58+
addressable-join:
59+
desc: addressable URI joining/merging paths
60+
addressable-merge:
61+
desc: addressable URI merging options
62+
addressable-new:
63+
desc: addressable URI construction from hash
64+
addressable-normalize:
65+
desc: addressable URI normalization
66+
addressable-parse:
67+
desc: addressable URI parsing (simple and complex URIs)
68+
addressable-setters:
69+
desc: addressable URI component setters (scheme, host, path modification)
70+
addressable-to-s:
71+
desc: addressable URI to string conversion
5472
binarytrees:
5573
desc: binarytrees from the Computer Language Benchmarks Game.
5674
blurhash:
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# frozen_string_literal: true
2+
3+
source "https://rubygems.org"
4+
5+
gem "addressable"
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
GEM
2+
remote: https://rubygems.org/
3+
specs:
4+
addressable (2.8.7)
5+
public_suffix (>= 2.0.2, < 7.0)
6+
public_suffix (6.0.2)
7+
8+
PLATFORMS
9+
aarch64-linux
10+
ruby
11+
12+
DEPENDENCIES
13+
addressable
14+
15+
BUNDLED WITH
16+
2.6.9
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
require_relative "../../harness/loader"
2+
3+
Dir.chdir __dir__
4+
use_gemfile
5+
6+
require "addressable/uri"
7+
8+
run_benchmark(100) do
9+
10000.times do
10+
# URI equality comparison
11+
uri1 = Addressable::URI.parse("http://example.com")
12+
uri2 = Addressable::URI.parse("http://example.com:80/")
13+
uri1 == uri2
14+
end
15+
end
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# frozen_string_literal: true
2+
3+
source "https://rubygems.org"
4+
5+
gem "addressable"
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
GEM
2+
remote: https://rubygems.org/
3+
specs:
4+
addressable (2.8.7)
5+
public_suffix (>= 2.0.2, < 7.0)
6+
public_suffix (6.0.2)
7+
8+
PLATFORMS
9+
aarch64-linux
10+
ruby
11+
12+
DEPENDENCIES
13+
addressable
14+
15+
BUNDLED WITH
16+
2.6.9
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
require_relative "../../harness/loader"
2+
3+
Dir.chdir __dir__
4+
use_gemfile
5+
6+
require "addressable/uri"
7+
8+
COMPLEX_URI = "https://user:[email protected]:8080/path/to/resource?query=value&foo=bar#fragment"
9+
10+
run_benchmark(100) do
11+
10000.times do
12+
# Component access
13+
uri = Addressable::URI.parse(COMPLEX_URI)
14+
uri.scheme
15+
uri.host
16+
uri.port
17+
uri.path
18+
uri.query
19+
uri.fragment
20+
end
21+
end
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# frozen_string_literal: true
2+
3+
source "https://rubygems.org"
4+
5+
gem "addressable"
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
GEM
2+
remote: https://rubygems.org/
3+
specs:
4+
addressable (2.8.7)
5+
public_suffix (>= 2.0.2, < 7.0)
6+
public_suffix (6.0.2)
7+
8+
PLATFORMS
9+
aarch64-linux
10+
ruby
11+
12+
DEPENDENCIES
13+
addressable
14+
15+
BUNDLED WITH
16+
2.6.9
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
require_relative "../../harness/loader"
2+
3+
Dir.chdir __dir__
4+
use_gemfile
5+
6+
require "addressable/uri"
7+
8+
run_benchmark(100) do
9+
10000.times do
10+
# URI joining
11+
base = Addressable::URI.parse("http://example.com/a/b/c")
12+
base.join("../d")
13+
end
14+
end

0 commit comments

Comments
 (0)