16

Well not bad for my first try eh? I implemented a std::vector-like container and it's about 4 times as fast as std::vector

Comments
  • 7
    How does it compare in terms of features and capabilities?
  • 3
  • 3
    @AlgoRythm
    Was going to say, if it's a generic replacement, submit it and they'll usually consider incorporating it into the next version.
  • 2
    @SortOfTested Wasn't looking to follow the bullshit that is c++. I wanted to implement a list structure using templates and c++ was the nicest language for that.
  • 4
    Details? std::vector is pretty fast, about the only time I've seen it go slow is when folks misuse the constructors, don't use emplace_back, or don't reserve memory in advance (it's literally just an array after all).
  • 1
    @RememberMe The benchmark is just construction and push_back'ing 1000 ints
  • 0
    @AlgoRythm so if i have to chose one from @RememberMe it would probably be that your implementation allocates memory in advance and the std does not. Or are you constructing 1000 vectors?
  • 1
    @hjk101 mine allocates 64 blocks in advance but I have also disabled this behavior with minimal effect on results.

    The process is create a new vector / list, start a for loop where i is 0 to 999, inc. push_back i

    The benchmark software repeats this process some amount of times. I don't know how many. But then it spits out this report.
  • 0
    @AlgoRythm that should not be possible. Allocating and accounting memory should be a large part of the overhead.
    Do you run both in a single application?

    I do not want to crap on your implementation or achievement. Just curious what is causing the significant gap. If you find it you might be on to something significant we can fix in std: vector
  • 0
    Also, how does the benchmark look if you reserve memory for std::vector at the beginning? Perhaps you could share your benchmark?
Add Comment