Quote:
Originally posted by oktronic
All there have reserve functions.
reserve for mine and STL and SetSize in CArray.
The object of the benchmark was to compare all three in the same situation and see how they held up. I'm pretty confident that the spread will remain the same if all situations were tested.
...
If I did all the benchmarks again with reserved memory, you would find that, while they all would be faster, that the spread would be about the same.
Pretty confident statement. Mind if you send me your code so I could test it?
Quote:
Originally posted by oktronic
In mine, the new operator is overloaded for custom memory allocation and for reserved memory operations. In this benchmark they all used default release mode new. So each had to grow dynamic. Which is important test since 90% of the time you don't know how much you are going to hold, such as a stream of data unless its polite enough to give you its size first. Many programs have the "Here's a bunch of data" philosophy.
But you still have not addressed the issue of using a linked list rather than a vector.
Quote:
Originally posted by oktronic
All three have a operator[] for indexing and assignment.
Mine only has retrieval not assignment to protect against array out of index. Done on purpose to force users to use the provided functions. By doing so, I don't get calls where I get blamed for exceptions, well I still get blamed, but I get a nice fee when I find the problem in the users code.
You're just limiting the feature set here. Nothing that really affects performance.
Quote:
Originally posted by oktronic
That's why I return bool, which will drop into replace vector. I think its pretty decided (except with MS with doesn't always) that a bool return type means, it worked or it didn't, so anybody using the class will need to check to ensure success, which is faster and less code for them then try-catch blocks and if there's a full system error and if you're using my construct, you'll be politely informed of the error and the program will even offer to save, clean up and restart the program an bring you back you were, if possible.
So I use boolean returns often and let the programmer or program construct manage the error.
Handling "problem cases" should not be taken into consideration of performance.
Quote:
Originally posted by oktronic
as for operator[], vector would probably be a little faster since all it does is get the begin pointer and add the offset. However if you're out of index it will crash. Mine on the other hand, verifies the index to be in bounds and will return an empty object type if it is, but I return a value not a reference so I can do that.
That's not necessarily true. The user can catch an exception. And what is an "empty" object? For an integer, is that zero? How would a program differentiate an "empty" integer from a valid integer? This could be very, very important for an application!!!
Quote:
Originally posted by oktronic
So again, its user preference, if you want a class that will not crash no matter what values you give it, or what functions you call, as well as some kickin' performance, create your own and put all you want in it.
You want some good performance and the price of debugging, user safety and your head exploding while looking at one of the header files, then use STL.
:rolleyes: Ok... if users don't want to catch exceptions that they know could be thrown, then yes a program can crash. However, the user would just then not be checking for errrors. In the case of your class, that would be analogous to the user not checking the return value of push_back. What would happen to a user application if they didn't catch that? I'm not sure.... it depends on the user app.
In the end though, you still have not addressed the issue of linked list vs. vector. Please comment!