Today I get a task to realise B tree and I am interesting whether unsafe code with fixed buffers will be more effective for working with disk? As we will work with whole segments but not with disparate segments of memory (as would be when we work with safe types and will try to copy "structs" which contains some different variables in different places in memory)? I am sorry if my question is not very concrete, but I don't understand how to concrete it without big piece of code. Thank you an advance.
-
1Performance questions are not answered easily - especially without code. Why don't you just try both variants? – Christoph Fink Apr 17 '14 at 10:29
-
I don't imagine how to do this test "clean" - without influence of other tasks in System, yet because my notebook is quite slow. – Evgeniy Kluchikov Apr 17 '14 at 10:34
-
Then run the test 10 (or even 100) times and get the average value. This should even out the side effects for both methods. As a comparison good enought - if they are "to close together" for a definite answer you should use the "safe way"... – Christoph Fink Apr 17 '14 at 10:37
-
Hm, thank you, I didn't think about such solution. Couldn't you advice an article or book where I could be read about alike techniques? As university program unfortunately don't have such things. – Evgeniy Kluchikov Apr 17 '14 at 10:41
-
I combined my comments to an answer and added my advice... – Christoph Fink Apr 17 '14 at 10:49
1 Answers
Performance questions are not answered easily - especially without code.
Why don't you just try both variants?
Then run the test 10 (or even 100 or more) times and get the average value.
This should even out the side effects for both methods - to compare good enought...
If they are "to close together" for a definite answer you should use the "safe way". Because IMO unsafe
should only be used if really necessary.
P.S.: I can't recommend any books or similar to such methods - "learning by doing" is my advice here. In such cases I also just try different things and analyze them, maybe search for different approaches or ask here for specific help with a short code example (already done here multiple times successfully). After that I most of the time have better and more performant code and learned something new...

- 22,727
- 9
- 68
- 113