> On Feb. 21, 2017, 7:14 p.m., Jason Lowe-Power wrote:
> > src/python/m5/stats/__init__.py, line 105
> > <http://reviews.gem5.org/r/3819/diff/1/?file=66043#file66043line105>
> >
> >     Can we make this a little more explicit? I think using decorators is a 
> > little clearer. Like:
> >     
> >     @_url_wrapper
> >     def initText(filename, desc=True):
> >         return _m5.stats.initText(filename, desc)
> >     
> >     In fact, you could even implicitly generate the factories dictionary. 
> > Though, this would be counter to my "more explicit" request ;).
> >     
> >     I'm pretty sure that _url_wrapper is already a correctly implemented 
> > decorator, but I don't have a ton of experience with them, so I could be 
> > wrong.

I have made the wrapper it into a proper decorator and the text visitor using a 
named function instead of a lambda now. One benefit of this is that we'll be 
able to use the doc string from the factories to print the documentation for 
the available stat formats. I haven't implemented the latter though.


- Andreas


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
http://reviews.gem5.org/r/3819/#review9443
-----------------------------------------------------------


On Feb. 21, 2017, 6:53 p.m., Andreas Sandberg wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> http://reviews.gem5.org/r/3819/
> -----------------------------------------------------------
> 
> (Updated Feb. 21, 2017, 6:53 p.m.)
> 
> 
> Review request for Default.
> 
> 
> Repository: gem5
> 
> 
> Description
> -------
> 
> Changeset 11873:c509be206026
> ---------------------------
> python: Add a generalized mechanism to configure stats
> 
> Add a mechanism to configure the stat output format using a URL-like
> syntax. This makes it possible to specify both an output format
> (currently, only text is supported) and override default
> parameters.
> 
> On the Python-side, this is implemented using a helper function
> (m5.stats.addStatVisitor) that adds a visitor to the list of active
> stat visitors. The helper function parses a URL-like stat
> specification to determine the stat output type. Optional parameters
> can be specified to change how stat visitors behave.
> 
> For example, to output stats in text format without stat descriptions:
> 
>     m5.stats.appendStatVisitor("text://stats.txt?desc=False")
> 
> From the command line:
> 
>     gem5.opt --stats-file="text://stats.txt?desc=False"
> 
> Internally, the stat framework uses the _url_wrapper() helper function
> to wrap a Python function with the fn(path, **kwargs) signature in a
> function that takes a parsed URL as its only argument. The path and
> keyword arguments are automatically derived from the URL in the
> wrapper function.
> 
> New output formats can be registered in the m5.stats.factories
> dictionary. This dictionary contains a mapping between format names
> (URL schemes) and factory methods.
> 
> To retain backwards compatibility, the code automatically assumes that
> the user wants text output if no format has been specified (i.e., when
> specifying a plain path).
> 
> Change-Id: Ic4dce93ab4ead07ffdf71e55a22ba0ae5a143061
> Signed-off-by: Andreas Sandberg <andreas.sandb...@arm.com>
> Reviewed-by: Curtis Dunham <curtis.dun...@arm.com>
> Reviewed-by: Sascha Bischoff <sascha.bisch...@arm.com>
> Reviewed-by: Ilias Vougioukas <ilias.vougiou...@arm.com>
> 
> 
> Diffs
> -----
> 
>   src/python/m5/main.py ba90ffa751b6 
>   src/python/m5/stats/__init__.py ba90ffa751b6 
> 
> Diff: http://reviews.gem5.org/r/3819/diff/
> 
> 
> Testing
> -------
> 
> 
> Thanks,
> 
> Andreas Sandberg
> 
>

_______________________________________________
gem5-dev mailing list
gem5-dev@gem5.org
http://m5sim.org/mailman/listinfo/gem5-dev

Reply via email to