Skip to content

[benchmark] Fix the Dictionary(group:by:) test #10306

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

Merged
merged 1 commit into from
Jun 17, 2017

Conversation

natecook1000
Copy link
Member

When testing quadratic behavior, remember to repeat small amounts of the behavior several times, not to increase the N, which is squared. 🙄

@natecook1000
Copy link
Member Author

@swift-ci Please smoke test and merge

@natecook1000
Copy link
Member Author

@swift-ci Please smoke test OS X platform

@natecook1000
Copy link
Member Author

@swift-ci Please test

@swift-ci
Copy link
Contributor

Build failed
Jenkins build - Swift Test OS X Platform
Git Commit - ac36c0e560837792c507236ab9712d8722b4c48c
Test requested by - @natecook1000

@najacque
Copy link
Contributor

We had more breakage on master. Should be fixed now... Let's try this again.
@swift-ci please test

@swift-ci
Copy link
Contributor

Build failed
Jenkins build - Swift Test OS X Platform
Git Commit - ac36c0e560837792c507236ab9712d8722b4c48c
Test requested by - @najacque

@natecook1000
Copy link
Member Author

@swift-ci Please test

@swift-ci
Copy link
Contributor

Build failed
Jenkins build - Swift Test OS X Platform
Git Commit - ac36c0e560837792c507236ab9712d8722b4c48c
Test requested by - @natecook1000

@natecook1000
Copy link
Member Author

@swift-ci Please test

@@ -39,9 +41,11 @@ class Box<T : Hashable> : Hashable {

@inline(never)
public func run_DictionaryGroupOfObjects(_ N: Int) {
let count = 20 * N
for _ in 1...N {
let count = 5_000
let result = count / 10
let dict = Dictionary(grouping: (0..<count).map { Box($0) }, by: { Box($0.value % 10) })
Copy link
Contributor

@palimondo palimondo Jun 16, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@natecook1000 This map is eager. Wouldn’t it make sense to create the [Box] outside of the top level for loop? I’m guessing your goal isn’t to measure the Box object creation, but the performance of grouping on reference counted objects on the heap, right?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about this?

let count = 5_000
let result = count / 10
let objects = (0..<count).map { Box($0) }

for _ in 1...N {
  let dict = Dictionary(grouping: objects, by: { Box($0.value % 10) })
  CheckResults(dict.count == 10)
  CheckResults(dict[Box(0)]!.count == result)
}

Copy link
Contributor

@palimondo palimondo Jun 16, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, as the N get's balanced by the benchmark driver, why not make the count same between DictionaryGroup and DictionaryGroupOfObjects, so that their respective ratio better reflects the change in work going from structs to classes?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dabrahams What do you think?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@palimondo All good points, thanks!

When testing quadratic behavior, remember to repeat small amounts of the
behavior several times, not to increase the N, which is squared. 🙄
@natecook1000
Copy link
Member Author

@swift-ci Please test

@swift-ci
Copy link
Contributor

Build failed
Jenkins build - Swift Test OS X Platform
Git Commit - ac36c0e560837792c507236ab9712d8722b4c48c
Test requested by - @natecook1000

@swift-ci
Copy link
Contributor

Build failed
Jenkins build - Swift Test Linux Platform
Git Commit - ac36c0e560837792c507236ab9712d8722b4c48c
Test requested by - @natecook1000

@palimondo
Copy link
Contributor

@natecook1000 Did you mean "please benchmark"?

@natecook1000
Copy link
Member Author

No, the change to benchmark is in #10275

@natecook1000
Copy link
Member Author

@swift-ci Please smoke test OS X platform

@natecook1000 natecook1000 merged commit c37c6f4 into swiftlang:master Jun 17, 2017
@natecook1000 natecook1000 deleted the nc-grouping-test branch October 4, 2018 15:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants