Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Track traits and overrides with FactoryProf #292

Open
palkan opened this issue May 4, 2024 · 0 comments · May be fixed by #296
Open

Track traits and overrides with FactoryProf #292

palkan opened this issue May 4, 2024 · 0 comments · May be fixed by #296
Labels
hackday RailsConf Hack Day challenges

Comments

@palkan
Copy link
Collaborator

palkan commented May 4, 2024

Context

Currently, we only track the factory name/id when collecting information about factories usage. However, for refactoring and context extraction purposes it would be useful to also see common variations (traits and attribute overrides).

TODO

Add variations information to the FactorProf data and print it in the FPROF=1 report. Example format:

[TEST PROF INFO] Factories usage

Total: 15285
...

    name           total   top-level   total time    time per call      top-level time           
    user            6091        2715    115.7671s          0.0426s            50.2517s 
     .admin          123         715     15.7671s          0.0466s             5.2517s 
     [name,role]      25          11       7.671s          0.0666s             1.2517s 
    post            2142        2098     93.3152s          0.0444s            92.1915s       
     .draft[tags]     12          12      9.3152s          0.164s             42.1915s        
  ...

In the example above, .xxx indicates a trait and [a,b] indicates the overrides keys, e.g., create(:user, :admin) is an .admin variation, while create(:post, :draft, tags: ["a"]).draft[tags]. We do not distinguish values, only schemas.

Implementation notes

  • FactoryProf collector should receive the variation name from the outside and should not deal with traits, overrides, etc. Thus, we need to extends the #track methods with the variation: keyword argument

  • Overrides keys and traits must be sorted (since the order doesn't matter)

  • It makes sense to add a specific variation id for variations with too many traits or overrides ("too many" must be configurable); e.g., create(:post, title: "RailsConf", publish_at: 2.days.since, tags: ["a", "b"], author: user) would be marked as [...].

@palkan palkan added the hackday RailsConf Hack Day challenges label May 4, 2024
@lHydra lHydra linked a pull request May 20, 2024 that will close this issue
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hackday RailsConf Hack Day challenges
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant