-
Notifications
You must be signed in to change notification settings - Fork 189
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
feat: Get Performance Data & Performance Data Types #422
feat: Get Performance Data & Performance Data Types #422
Conversation
I couldn't get 'cpuinfo' to work/return a good response. An error occurred each time, so I commented out the assertion |
@akinsolb Please provide the actual server error, perhaps I could fix it |
/// [1478098800, null, null, 4444433, 10227, 1430356, 10493, 0, 3600]] | ||
/// in case of cpu info : [[user, kernel], [0.9, 1.3]] | ||
/// </returns> | ||
IList<object> GetSupportPerformanceData(string packageName, string dataType, int dataReadTimeout = 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does zero value mean the timeout is not limited?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't even remember the specification for the timeout. When I do, i'll add it to the xml documentation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually, I've jus checked the source code. The argument name is confusing. The value means how many times the perf data retrieval operation should be retried in case of failure: https://github.com/appium/appium-android-driver/blob/c1a8ee54b69e14940d4c2ecb766be7f75235aba2/lib/commands/performance.js#L69
The default value is 2 with 1000ms delays between each retry
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I set this to 0 the appium logs doesn't display a second attempt, it just returns null.
- I'm going to change the parameter to dataReadAttempts and update the param notes to make this clearer.
- Set the default value of dataReadAttempts to 1 because setting it to 0 returns null from the server (1.18).
- Prevent users from setting 0 as the default value
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
made the above changes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would rather create an overloaded method without this parameter. As far as I can see it is optional, so you could just skip sending it to the server: https://github.com/appium/appium-base-driver/blob/eba4635dcd8fe81899c3349d7e474acfb66037e7/lib/protocol/routes.js#L380
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could either create an overload method or perform a check on the method parameter, as it's optional, it already works as an overload to users
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it? We are always sending the dataReadTimeout
arg in https://github.com/appium/appium-dotnet-driver/pull/422/files#diff-db1821172278290200c0e11b4a1a7b1dR120
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changes made
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An alternative is making the dataReadAttempts argument nullable on the driver like so:
public IList<object> GetPerformanceData(string packageName, string performanceDataType, int? dataReadAttempts = null)
and checking for the value in the android command executor like so:
public static object[] GetPerformanceData(IExecuteMethod executeMethod, string packageName, string dataType, int? dataReadTimeout)
`{
var requiredKeys = new [] {"packageName", "dataType"};
var requiredKeyValues = new object[] {packageName, dataType};
if (dataReadTimeout is null)
return executeMethod.Execute(AppiumDriverCommand.GetPerformanceData,
PrepareArguments(requiredKeys, requiredKeyValues)).Value as object[];
requiredKeys.SetValue("dataReadTimeout", 2);
requiredKeyValues.SetValue(dataReadTimeout, 2);
return executeMethod.Execute(AppiumDriverCommand.GetPerformanceData,
PrepareArguments(requiredKeys, requiredKeyValues)).Value as object[];
}`
https://gist.github.com/akinsolb/78d3343b39baf2f989f8e5a21c8c4a52 This is a run on an emulator (Android 10) |
Update documentation
public IList<object> GetPerformanceData(string packageName, string performanceDataType, | ||
int dataReadAttempts = 1) | ||
{ | ||
if (dataReadAttempts < 1) throw new ArgumentException($"{nameof(dataReadAttempts)} must be greater than 0"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
I've pushed appium/appium-android-driver#659 to fix the issue #422 (comment) You could check it out locally and verify now or wait until it's approved and is merged to beta |
Thanks. I'll wait till it's merged into beta. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the cpuinfo fix has been published
closes #361
Change list
Please provide briefly described change list which are you going to propose.
Types of changes
What types of changes are you proposing/introducing to .NET client?
Put an
x
in the boxes that applyDocumentation
This can be done by navigating to the documentation section on http://appium.io selecting the appropriate command/endpoint and clicking the 'Edit this doc' link to update the C# example
Integration tests
Details
Adds support for getting performance data and performance data types on Android
Adds the following methods to AndroidDriver.cs
GetPerformanceDataTypes()
GetPerformanceData(packageName,dataType,dataReadTimeout)
Please provide more details about changes if it is necessary. If there are new features you can provide code samples which show the way they
work and possible use cases. Also you can create gists with pasted C# code samples or put them here using markdown.
About markdown please read Mastering markdown and Writing on GitHub