|
|
|
#1 |
|
Messages: n/a
Hébergeur: |
I have to run the simulation of a trace file around (7gb contains
116million entries)... presently i am using vector iterators to check the conditions in my program..... it is taking 2 days to finish whole simulation..... my question are the map iterators are faster than vector iterators..... does it improve the performance.... thanks to all |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
On Jul 2, 9:31am, xyz <lavanyaredd...@gmail.com> wrote:
> I have to run the simulation of a trace file around (7gb contains > 116million entries)... > presently i am using vector iterators to check the conditions in my > program..... > it is taking 2 days to finish whole simulation..... > > my question are the map iterators are faster than vector > iterators..... > does it improve the performance.... > thanks to all Since a vector is guarenteed to be contiguous memory, it's iterator *could* be implemented internally as a pointer - which is fast. A map is list-like in that is has nodes so it's iterator would have to dereference a pointer - which is slower. So, in very general terms, I think maps iterators would be slower. But... Use a good profiler to determine which parts of your program are time consuming. Without a profiler, you're just guessing. HTH |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
xyz <lavanyareddy.p@gmail.com> wrote in news:fb7c6ce6-5af3-4e24-8a0b-
dc4940bbfcca@25g2000hsx.googlegroups.com: > I have to run the simulation of a trace file around (7gb contains > 116million entries)... > presently i am using vector iterators to check the conditions in my > program..... > it is taking 2 days to finish whole simulation..... > > my question are the map iterators are faster than vector > iterators..... > does it improve the performance.... > thanks to all > I am not sure what operations you are performing on your iterators, but vector iterators are about as fast as you get. Maps are generally a tree structure of some sort and moving from one node to the next will generally require loading a value from memory whereas with a vector, it will simply add or subtract a fixed amount from the address already in the iterator. This tends to be faster. Same thing applies to a list. Vectors also have better locality of reference so when an item is read, the whole page comes into memory and you get the objects surrounding the target for free. maps, sets, lists etc are better if their semantics match what you want to do better. That is, if you find yourself searching for objects a lot, then maps and sets are more natural. Though even then, sorting the vector and using the binary search algorithms may perform better. The other thing to consider is that maps, sets, and lists have more overhead per object. With 116M objects, that can add up. HTH, joe |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
Joe Greer <jgreer@doubletake.com> wrote in
news:Xns9ACF63DE02FB0jgreerdoubletakecom@85.214.90 .236: > xyz <lavanyareddy.p@gmail.com> wrote in news:fb7c6ce6-5af3-4e24-8a0b- > dc4940bbfcca@25g2000hsx.googlegroups.com: > >> I have to run the simulation of a trace file around (7gb contains >> 116million entries)... >> presently i am using vector iterators to check the conditions in my >> program..... >> it is taking 2 days to finish whole simulation..... >> >> my question are the map iterators are faster than vector >> iterators..... >> does it improve the performance.... >> thanks to all >> > > I am not sure what operations you are performing on your iterators, > but vector iterators are about as fast as you get. Maps are generally > a tree structure of some sort and moving from one node to the next > will generally require loading a value from memory whereas with a > vector, it will simply add or subtract a fixed amount from the address > already in the iterator. This tends to be faster. Same thing applies > to a list. Vectors also have better locality of reference so when an > item is read, the whole page comes into memory and you get the objects > surrounding the target for free. maps, sets, lists etc are better if > their semantics match what you want to do better. That is, if you > find yourself searching for objects a lot, then maps and sets are more > natural. Though even then, sorting the vector and using the binary > search algorithms may perform better. The other thing to consider is > that maps, sets, and lists have more overhead per object. With 116M > objects, that can add up. > > HTH, > joe > I also agree with the comment to use a profiler to be sure you are optimizing the proper thing. joe |
|
|
|
#5 |
|
Messages: n/a
Hébergeur: |
On Jul 2, 3:49pm, Joe Greer <jgr...@doubletake.com> wrote:
> xyz <lavanyaredd...@gmail.com> wrote in news:fb7c6ce6-5af3-4e24-8a0b- > dc4940bbf...@25g2000hsx.googlegroups.com: > > > I have to run the simulation of a trace file around (7gb contains > > 116million entries)... > > presently i am using vector iterators to check the conditions in my > > program..... > > it is taking 2 days to finish whole simulation..... > > > my question are the map iterators are faster than vector > > iterators..... > > does it improve the performance.... > > thanks to all > > I am not sure what operations you are performing on your iterators, but > vector iterators are about as fast as you get. Maps are generally a tree > structure of some sort and moving from one node to the next will generally > require loading a value from memory whereas with a vector, it will simply > add or subtract a fixed amount from the address already in the iterator. > This tends to be faster. Same thing applies to a list. Vectors alsohave > better locality of reference so when an item is read, the whole page comes > into memory and you get the objects surrounding the target for free. maps, > sets, lists etc are better if their semantics match what you want to do > better. That is, if you find yourself searching for objects a lot, then > maps and sets are more natural. Though even then, sorting the vector and > using the binary search algorithms may perform better. The other thingto > consider is that maps, sets, and lists have more overhead per object. With > 116M objects, that can add up. > > HTH, > joe for example i am doing the operation as below in my program whenever i receive a packet or something ...i will check does it contain in my vector list.... so if I contain around 2 million entreis in my vector and i received around 100 packets... then the computation would be 100 packets * 2 million iterations... as my list goes on incresing I will have more iterations.. this is the problem i am facing with my simulation.. |
|
|
|
#6 |
|
Messages: n/a
Hébergeur: |
On Jul 2, 3:50pm, Joe Greer <jgr...@doubletake.com> wrote:
> Joe Greer <jgr...@doubletake.com> wrote innews:Xns9ACF63DE02FB0jgreerdoubletakecom@85.214. 90.236: > > > > > xyz <lavanyaredd...@gmail.com> wrote in news:fb7c6ce6-5af3-4e24-8a0b- > > dc4940bbf...@25g2000hsx.googlegroups.com: > > >> I have to run the simulation of a trace file around (7gb contains > >> 116million entries)... > >> presently i am using vector iterators to check the conditions in my > >> program..... > >> it is taking 2 days to finish whole simulation..... > > >> my question are the map iterators are faster than vector > >> iterators..... > >> does it improve the performance.... > >> thanks to all > > > I am not sure what operations you are performing on your iterators, > > but vector iterators are about as fast as you get. Maps are generally > > a tree structure of some sort and moving from one node to the next > > will generally require loading a value from memory whereas with a > > vector, it will simply add or subtract a fixed amount from the address > > already in the iterator. This tends to be faster. Same thing applies > > to a list. Vectors also have better locality of reference so when an > > item is read, the whole page comes into memory and you get the objects > > surrounding the target for free. maps, sets, lists etc are better if > > their semantics match what you want to do better. That is, if you > > find yourself searching for objects a lot, then maps and sets are more > > natural. Though even then, sorting the vector and using the binary > > search algorithms may perform better. The other thing to consider is > > that maps, sets, and lists have more overhead per object. With 116M > > objects, that can add up. > > > HTH, > > joe > > I also agree with the comment to use a profiler to be sure you are > optimizing the proper thing. > > joe I have already used the profiler to know the time consuming places in my program.... I checked smaller protion of my 7gb file...which showed the time consuming part is at what i mentioned |
|
|
|
#7 |
|
Messages: n/a
Hébergeur: |
xyz wrote:
> I have to run the simulation of a trace file around (7gb contains > 116million entries)... > presently i am using vector iterators to check the conditions in my > program..... > it is taking 2 days to finish whole simulation..... > > my question are the map iterators are faster than vector > iterators..... > does it improve the performance.... It's not a question of iterators. It's a question of what is it that you are doing with your vector/map and how you are using those iterators. (And no, when measured in clock cycles, no operation done to a map iterator is faster than to a vector iterator. On the contrary. However, I have the feeling you are not really talking about the iterators per se.) |
|
|
|
#8 |
|
Messages: n/a
Hébergeur: |
"xyz" <lavanyareddy.p@gmail.com> wrote in message
news:fb7c6ce6-5af3-4e24-8a0b-dc4940bbfcca@25g2000hsx.googlegroups.com... >I have to run the simulation of a trace file around (7gb contains > 116million entries)... > presently i am using vector iterators to check the conditions in my > program..... > it is taking 2 days to finish whole simulation..... > > my question are the map iterators are faster than vector > iterators..... > does it improve the performance.... > thanks to all Performance for what? Insertions? Deletions? Insertions in middle? End? Beginning? Deletion is middle? End? Beginning? Lookups in beginning? End? Middle? Different containers (vector, set, map, etc...) are designed for different tasks and each has it's power and it's weakness. Maybe this link will : http://www.linuxsoftware.co.nz/cppcontainers.html maybe it won't. Check the bottom anyway to determine which container to chose. Also, the wiki has a little bit about the speed of some of the containers: http://en.wikipedia.org/wiki/Standard_Template_Library Really, without knowing what you are trying to optmize it is hard to say. std::vector<MyClass> MyVector; /*... */ MyVector[SomeCounter] should be a relatively fast operation, very similar to pointer math. std::map<Mykey, MyClass> MyMap; /* ... */ MyMap.find( SomeKey ); is a binary search lookup. MyMap[SomeKey] is also a binary key lookup, with the additon of possibly adding the key and data. Without knowing how you are using the vector it is hard to say. One thing I would hope, however is that you are preallocating enough memory for your vector so that it doesn't have to keep newing when it runs out of memory. I have no idea why your operation is taking 2 days, maybe it should be. Maybe it shouldn't. :But without knowing more about what you are actually doing anything we come up with is a shot in the dark. |
|
![]() |
| Outils de la discussion | |
|
|