Coder Social home page Coder Social logo

weird chrono time about articles HOT 8 CLOSED

wichtounet avatar wichtounet commented on July 23, 2024
weird chrono time

from articles.

Comments (8)

borissmidt avatar borissmidt commented on July 23, 2024

I have been able to implement some iterators for my custom pointer vector but i still have the chrono timing bug.
But if the time is correct then a vector of pointers is faster than a vector from array sizes of 128. But i cannot really compare it to the other errors because of the timing error.

from articles.

borissmidt avatar borissmidt commented on July 23, 2024

I have solved it by explicitly setting the duration to 0 .
The benchmarks of my wrapped pointer vector show that it is faster than a vector at random insert from size 128. i will soon run all the tests.
But i think the pointer vector could be faster if i could somehow pre allocate reserved space. for example with a memory pool but i geuss this is too complex for me now.

from articles.

wichtounet avatar wichtounet commented on July 23, 2024

Hi,

Sorry about that. I've slightly changed the timing function, it should not have these weird numbers anymore. Could you check again ?

Yes, it is likely that if you reserve the memory in a single block, it will be faster because of very good data locality of the pointers.

from articles.

borissmidt avatar borissmidt commented on July 23, 2024

yea i used the same solution aswell to solve the chrono problem. i have the results in, the ptr vector seems faster than a linked list. But i guess the vector implementation is verry naive since it only allocated on an incert like a linked list and i am certain it could be made faster with a memory pool instead like a vector or deque. So then the performance would probably be between a deque and vector. except the fill back. the graph is html but github doesn't support it.

graph.txt
here is the naive ptr vector implementation. i quess i learned a thing or two from using you highly templated benchmark.
pointer_vector.txt

from articles.

borissmidt avatar borissmidt commented on July 23, 2024

Maybe in the future when i'm better at programming C++ i could program my own pointer vector where which uses an allocator to pre allocate a memory block for the container. So the container becomes less naive and has some capacity reserved.

from articles.

wichtounet avatar wichtounet commented on July 23, 2024

If you use vector as an underlying implementation, you at least have memory reserve for the pointers, but indeed it would probably be faster to have a memory pool for the objects themselves, but this is not trivial work.

I don't get the difference between const_iterator and iterator in your implementation. You use *a in iterator (which seems correct) for operator and &a in const_iterator. Otherwise, it seems quite good 👍

from articles.

borissmidt avatar borissmidt commented on July 23, 2024

Yea i should come back later to it if i ever need it. But i guess a ponter vector + memory pool is almost like a deque in its structure but with more direct acces.

But the iterators do not implement enough for the c++ sort method. and thank for the complement.

from articles.

wichtounet avatar wichtounet commented on July 23, 2024

I'm closing this issue, please reopen if there are still problems with this.

from articles.

Related Issues (10)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.