Skip to content

Commit 0dd9524

Browse files
Updated results after latest commits
Changes can be found in this branch: #3211
1 parent f88650e commit 0dd9524

File tree

1 file changed

+18
-25
lines changed

1 file changed

+18
-25
lines changed

experiments/lazy_load.md

Lines changed: 18 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,17 @@
11
# Lazy load experiment results
22

3-
- Git Branch: [sb-ta/lazy-load-experiment](https://github.com/faker-ruby/faker/compare/main...sb-ta/lazy-load-experiment)
4-
- Date: February 10th, 2026
5-
- Owner(s): Stefanni Brasil and Thiago Araujo
3+
Branch: sb-ta/lazy-load-experiment
4+
Date: February 10th, 2026
5+
Owner(s): Stefanni Brasil and Thiago Araujo
66

77
## Impact
88

99
Using `const_missing` to lazy load generators was an idea from talking with Jeremy Evans, who kindly responded our questions about improving faker's performance.
1010

1111
### Changes needed
1212

13-
#### Namespace changes
14-
15-
A few generators had namespaces that didn't match their file name, and most of them were manageable, but two needed to be renamed:
16-
17-
- `Faker::Music` -> `Faker::Song`. `Faker::Music` is a nested namespace.
18-
- `Faker::Internet::HTTP` -> `Faker::HTTP`. `Faker::Internet` is another generator.
19-
20-
Considering that only two generators would be renamed, it wouldn't be a huge burden for users to use this approach.
13+
Would require loading `faker/music` and `faker/internet` first, before the nested namespaces such as `Faker::Music::BossaNova`,
14+
as they inherit from class `Music`.
2115

2216
#### File location changes
2317

@@ -27,21 +21,18 @@ To prevent other generators from erroring out due to namespace clashing, some ge
2721

2822
- no additional dependencies needed
2923
- code is extremely faster
30-
- after changing these two generators, which would be breaking changes, we can enable this as an opt-in configuration
24+
- we can enable this as an opt-in configuration
3125

3226
## Results
3327

34-
profiler:
28+
Machine specs: Apple M1 Pro 16GB memory on MacOS Sequoia 15.7.3..
3529

36-
- [bundle exec vernier run -- ruby -e "require 'faker'" LAZY_LOAD=1](https://share.firefox.dev/3ZuCP55)
37-
- [bundle exec vernier run --interval 100 --allocation-interval 10 -- ruby -e "require 'faker'; Faker::Internet.email" LAZY_LOAD=1](https://share.firefox.dev/4601PoA)
30+
profiler:
3831

39-
benchmarks (Machine specs: Apple M1 Pro 16GB memory on MacOS Sequoia 15.7.3.)
32+
[LAZY_LOAD=1 bundle exec vernier run -- ruby -e "require 'faker'"](https://share.firefox.dev/46biNAs)
33+
[bundle exec vernier run -- ruby -e "require 'faker'"](https://share.firefox.dev/4ams9vM)
4034

41-
```sh
42-
benchmark % ruby require.rb
43-
took 250.0249999575317ms to load
44-
```
35+
benchmark:
4536

4637
```sh
4738
benchmark % ruby load.rb
@@ -50,17 +41,19 @@ Warming up --------------------------------------
5041
require 1.000 i/100ms
5142
lazyload 1.000 i/100ms
5243
Calculating -------------------------------------
53-
require 5.874 (± 0.0%) i/s (170.25 ms/i) - 30.000 in 5.115652s
54-
lazyload 12.2078.2%) i/s (81.92 ms/i) - 61.000 in 5.007059s
44+
require 4.698 (± 0.0%) i/s (212.88 ms/i) - 24.000 in 5.133782s
45+
lazyload 9.7510.0%) i/s (102.55 ms/i) - 49.000 in 5.032161s
5546

5647
Comparison:
57-
require: 5.9 i/s
58-
lazyload: 12.2 i/s - 2.08x faster
48+
require: 4.7 i/s
49+
lazyload: 9.8 i/s - 2.08x faster
5950
```
6051

6152
## Artifacts
6253

63-
Constants were configured to be lazy loaded using this script:
54+
### Scripts
55+
56+
Constants were registered using this script:
6457

6558
```ruby
6659
# lazy_load.rb

0 commit comments

Comments
 (0)