-
- Notifications
You must be signed in to change notification settings - Fork 1k
Compare parameters by object value rather than string representation (Related to #2838) #2887
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
Conversation
| The failing exporter checks seem to be because I changed the schema of the logical group keys, is there a way I could update what verify is expecting? E.g. verify expects |
| I guess I could have logical groups have a key for grouping and a display name for errors, but I feel this would just add unnecessary nonfunctional code |
| You can just update the verified files. |
Won't this not affect the CI though? |
I don't understand the question. The test compares the output of the run to the verified file. |
Sorry, didn't realize that the GitHub actions pulled tests from my PR and not master. Will implement these changes. |
…n lengths are different
| This effectively closes #2838 because it correctly groups parameters into different groups based on value. However, since the example in #2838 passes randomly generated parameters will improper seeding, the ratios won't come out as desired. If the parameters are properly seeded to be deterministic and effectively constant across calls of the ArgumentsSource, then the desired behavior will be exhibited. With super large arrays like the ones in #2838, though, the report generation takes a few minutes (I think its because of a lot of repeated value comparison work when sorting for the summary table) |
That's likely due to the boxing of every element. Perhaps it can be accelerated by using Btw, apparently md arrays throw from |
| I already flatten all enumerators (including md arrays) into an Another solution I was thinking of was to id parameters with indices of the order they were returned from ArgumentsSource/Arguments attribute with; this would avoid having to do object comparison entirely as we could use the indices to track params |
Right, and that flattening is the expensive part, because it boxes every element. My idea is first check for
It's clever, but it won't work because 2 methods can have |
| Thanks for clarifying, will do! |
| I implemented the changes for ParameterComparer but realized that it alone is not actually the culprit, so I reverted a few of the things (like the special case methods) to maintain simplicity. I'm currently investigating to see what else might be causing the slowdown |
| Ok, so it was a combination of ParameterComparer and ParameterEqualityComparer. It's sped up by magnitudes now. Thanks for the suggestion! |
Added a TODO note for performance.
| Thanks for restructuring the fallbacks |
| Is it guaranteed that the Orderer will always receive the same |
No, the orderer is a singleton, unfortunately. It will receive the same cases per summary, but users can run multiple times to get multiple summaries. |
| Or we could overload It was a quick thing so I tried it out already and I can push it if you'd like |
How? It's called from more than just Summary. |
| I left the old method signsture in place which is non-caching, and there is another one for summaries that is caching |
| Let's just leave it for now. We can refactor the interface separately. Thanks. |
| I optimized it in e0adbb9 to just scan the array once instead of building a set and then scanning the set. |
This is related to issue #2838 and PR #2886
Previous Behavior
Parameters and arguments passed to benchmarks were grouped into logical groups based on
ParameterInstances.ValueInfo(a string representation), which failed for types like arrays (whose string representations just contain length and element type), (partially) causing #2838. Any type where objects are not equal but can have the sameToString()was affected by this behavior.New Behavior
When using
DefaultOrdererto group benchmark cases, parameters are compared by their actual value as opposed to their string representations, leading to correct benchmark case grouping. This is done throughParameterEqualityComparer, so any parameter or custom wrapping struct for a parameter overridingobject.Equalswill now be properly distinguished regardless of itsToStringoverride. For anyIEnumerables (both non-generic and generic), there is now built-in functionality inParameterComparerwhich compares enumerables element-by-element for value-based equality.