-
-
Notifications
You must be signed in to change notification settings - Fork 978
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
Feature Request: allow to extend and/or parametrize RPlotExporter, or at least specify custom R script #2620
Comments
Hello @NinjaCross ! I am fine with the first two points, but when it comes to making What kind of customizations would you like to make? When it comes to specifying custom R script we could achieve that by moving the logic that computes the path to a virtual property, so just overriding a single property would get you what is needed. An alternative would be to make the path a parameter of the Thanks! |
Hi @adamsitnik , thanks for ther feedback !
I understand, it's an absolutely reasonable motivation.
In my specific case, I needed to use a dynamically-generated custom R script.
All that, could be avoided by allowing to inherit from
That would indeed solve some trivial scenarios where the R script is static, but since generating charts is a complex topic, it would not be enough for all users, and for more complex senarios. This is my proposal, with a very minimal impact: protected virtual (string Content, string FileName) GetScript(Summary summary, ILogger consoleLogger, string csvFullPath)
{
var scriptFileName = "BuildPlots.R";
var content = ResourceHelper.
LoadTemplate(scriptFileName).
Replace("$BenchmarkDotNetVersion$", BenchmarkDotNetInfo.Instance.BrandTitle).
Replace("$CsvSeparator$", CsvMeasurementsExporter.Default.Separator);
return (content, scriptFileName);
}
public IEnumerable<string> ExportToFiles(Summary summary, ILogger consoleLogger)
{
string csvFullPath = CsvMeasurementsExporter.Default.GetArtifactFullName(summary);
var (script, scriptFileName) = GetScript(summary, consoleLogger, csvFullPath);
yield return Path.Combine(summary.ResultsDirectoryPath, scriptFileName);
string scriptFullPath = Path.Combine(summary.ResultsDirectoryPath, scriptFileName);
const string logFileName = "BuildPlots.log";
string logFullPath = Path.Combine(summary.ResultsDirectoryPath, logFileName); I would be glad to prepare a PR, if you want. |
Please go ahead and send the PR, I am happy to review it. |
The current implementation (v0.14.0) of
RPlotExporter
(src/BenchmarkDotNet/Exporters/RPlotExporter.cs) works OK and IMHO is nicely implemented, but lacks for flexibility, because:IExporterDependencies
,RuntimeInformation
,ExporterBase.GetArtifactFullName
, andAsyncProcessOutputReader
)This greately limits the usability of such wonderfull feature.
I propose to:
RPlotExporter
is implemented, so that it can be easily inherited and customized by overriding some methodsIExporterDependencies
,RuntimeInformation
, andAsyncProcessOutputReader
aspublic
instead ofinternal
, so that they can be referred by inherited classes and other custom-made exportersI'm available to prepare a PR, if the proposal is deemed usefull.
The text was updated successfully, but these errors were encountered: