I am also still exploring Swift, so forgive me if I got this wrong, but isn't the problem here the following: Your RenderGradient() take...
I am also still exploring Swift, so forgive me if I got this wrong, but isn't the problem here the following: Your RenderGradient() takes a RenderBuffer struct. Structs are passed by value. So two things happen in your RenderBuffer function: 1) You get a copy of the RenderBuffer, which means it and its contents (a lot of Pixel instances - Arrays are passed by value too!) will be copied every iteration 2) The work you do on the pixels in the RenderBuffer copy has no effect: you change the values of a copy and then ignore the copy. You don't return the modified RenderBuffer it from RenderGradient() or do anything with the result within RenderGradient(). So I think the reason you see such a big difference in this test between optimization and no-optimization is that in the first case, with optimization, the compiler knows that the work you do in RenderBuffer is a waste of time and simply does not do it. While in the debug build the compiler does not apply optimization so your useless code is still executed. You can confirm this by looking at the generated code. Or maybe simpler, render the RenderBuffer in an actual buffer or image for a visual inspection.
Posted by st3fan on Jan 31, 2015, 1:18 PM
Tags
Related issues
- That isn't really relevant for the tool starting the container.
- Why is there no link to the source?
- Something I wonder about in this domain is if this is the fault of the language.
- Namespace pollution is an annoying problem in Rust.
- Currently, no language ports of Timefold Solver are planned.
- I agree with you, almost all .NET code I write is within the .NET framework, yet when I look at C# repos, it's disheartening to see so ma...
Raise real-world problems, find people facing the same issue, and discuss solutions.8,000 issues0 comments
hackernews (Software)
That isn't really relevant for the tool starting the container.
Why is there no link to the source?
Something I wonder about in this domain is if this is the fault of the language.
Namespace pollution is an annoying problem in Rust.
Currently, no language ports of Timefold Solver are planned.
I agree with you, almost all .NET code I write is within the .NET framework, yet when I look at C# repos, it's disheartening to see so ma...
Why is there no simple workaround for this?
I have been using https://github.com/jacktasia/dumb-jump to quickly jump to definitions.
I am also still exploring Swift, so forgive me if I got this wrong, but isn't the problem here the following: Your RenderGradient() take...
I am also still exploring Swift, so forgive me if I got this wrong, but isn't the problem here the following: Your RenderGradient() takes a RenderBuffer struct. Structs are passed by value. So two things happen in your RenderBuffer function: 1) You get a copy of the RenderBuffer, which means it and its contents (a lot of Pixel instances - Arrays are passed by value too!) will be copied every iteration 2) The work you do on the pixels in the RenderBuffer copy has no effect: you change the values of a copy and then ignore the copy. You don't return the modified RenderBuffer it from RenderGradient() or do anything with the result within RenderGradient(). So I think the reason you see such a big difference in this test between optimization and no-optimization is that in the first case, with optimization, the compiler knows that the work you do in RenderBuffer is a waste of time and simply does not do it. While in the debug build the compiler does not apply optimization so your useless code is still executed. You can confirm this by looking at the generated code. Or maybe simpler, render the RenderBuffer in an actual buffer or image for a visual inspection.
Comments (0)
No comments yet. Start the discussion.