Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Stopwatch] add retrieval of sections #10145

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

Closed
havvg opened this issue Jan 27, 2014 · 5 comments
Closed

[Stopwatch] add retrieval of sections #10145

havvg opened this issue Jan 27, 2014 · 5 comments
Labels
Good first issue Ideal for your first contribution! (some Symfony experience may be required) Stopwatch

Comments

@havvg
Copy link
Contributor

havvg commented Jan 27, 2014

I'm on to visualizing stopwatch data. However, I can't find any valid way to retrieve sections of a stopwatch.

There is Stopwatch::getSectionEvents($id), only. This method however requires to know which sections are available. How to retrieve those sections without relying on internals of the component?

@thunderer
Copy link
Contributor

Will getter for private attribute Stopwatch::$sections do the job? IMHO there is little possibility of doing it another way. If it's a good idea I can submit such PR.

@maxromanovsky
Copy link
Contributor

@havvg Where are you trying to visualize the Stopwatch data? According to TimeDataCollector it's possible to fetch it using the Debug token (given we are in the profiler or using the debug mode).
If it's possible then I suggest to use this token to fetch the data.

@fabpot Correct me if I'm wrong, but according to the Stopwatch class it supports infinite depth of Section nesting. But the TimeDataCollector supports only one level of nesting. Is it OK?
And another question. How should we behave if we have to fetch Stopwatch events without any knowledge of debug tokens or whatever other knowledge of sections? I don't think that exposing an internal Section class is a good idea since it provides read/write access to the Events. I think that good solution would be to expose a read-only projections of the Section class which would be aware of the hierarchy and events.

@havvg
Copy link
Contributor Author

havvg commented May 2, 2014

@maxromanovsky I'm outside of the framework, just plain Stopwatch Component. I get an instance of the Stopwatch class, and now I want to visualize the data of that Stopwatch: sections, subsections (tree structure) and their respective events. As your link to the TimeDataCollector reads, it's required to have knowledge about the existing sections, otherwise you cannot access them.

My intension of this issue was more like getting feedback on how to actually solve this issue. The Section class is marked for internal use. So I'm not sure, whether exposing the objects Stopwatch::$sections is a way to go. This would ultimately move Section into public namespace (well, it currently is, but you know what I mean). The documentation doesn't reflect, why this class is marked internal.

Re-factoring this into a more open variant is simple (e.g. adding an ImmutableStopwatch, ..), but is it fine, too?

@maxromanovsky
Copy link
Contributor

@havvg Let's wait for the decision of Fabien or other guys from Core Team.

@fabpot
Copy link
Member

fabpot commented May 4, 2014

I don't really remember why Section was made private back then. I think it makes sense to let anyone introspect/traverse the sections, so making everything "public" makes sense I think.

fabpot added a commit that referenced this issue Jun 6, 2014
This PR was squashed before being merged into the 2.3-dev branch (closes #10851).

Discussion
----------

Added retrieval of sections

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #10145
| License       | MIT

Commits
-------

7928767 Added retrieval of sections
@fabpot fabpot closed this as completed Jun 6, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Good first issue Ideal for your first contribution! (some Symfony experience may be required) Stopwatch
Projects
None yet
Development

No branches or pull requests

4 participants