-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Clean up the Perlin noise benchmark #12270
Conversation
All the style fixes look great to me, but did you see a perf improvement when siwtching from |
permutations: permutations, | ||
} | ||
let mut rgradients = [Vec2 { x: 0.0, y: 0.0 }, ..256]; | ||
for i in range(0, 256) { rgradients[i] = random_gradient(&mut rng); } |
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.
Why not iterators? for x in rgradients.mut_iter() { *x = random_gradient(&mut rng); }
@alexcrichton Although this version does run faster than the prior one, it's very slight... only two hundredths of a second faster, on average, on a machine that is pretty slow to begin with. I had no idea that println! was buffered, I do much prefer the look of it, so I'll make that change. |
Actually, the switch from |
@@ -8,128 +8,112 @@ | |||
// option. This file may not be copied, modified, or distributed | |||
// except according to those terms. | |||
|
|||
// Perlin noise benchmark from https://gist.github.com/1170424 | |||
// Multi-language Perlin noise benchmark. |
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.
Multi-language?
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.
Check out the link in the next line, there's D, Nimrod, Go, C, C#, lots more. Lots of the structure of this code is the way it is in order to remain easily comparable to these other implementations.
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.
Oh, cool!
And we're winning \o/
r=me after squashing |
Mostly just style fixes, but also remove a heap allocation and switch to using a buffered writer rather than doing 60,000 `println!`s.
`lint_groups_priority`: ignore lints & groups at the same level Fixes rust-lang#12270 changelog: none
Mostly just style fixes, but also remove a heap allocation and switch to using a buffered writer rather than doing 60,000
println!
s.