You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
10
10
11
11
### Changes needed
12
12
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`.
21
15
22
16
#### File location changes
23
17
@@ -27,21 +21,18 @@ To prevent other generators from erroring out due to namespace clashing, some ge
27
21
28
22
- no additional dependencies needed
29
23
- 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
31
25
32
26
## Results
33
27
34
-
profiler:
28
+
Machine specs: Apple M1 Pro 16GB memory on MacOS Sequoia 15.7.3..
35
29
36
-
-[bundle exec vernier run -- ruby -e "require 'faker'" LAZY_LOAD=1](https://share.firefox.dev/3ZuCP55)
0 commit comments