Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. ATL / WTL / STL
  4. STL set.h Performance Analysis

STL set.h Performance Analysis

Scheduled Pinned Locked Moved ATL / WTL / STL
c++performancehelptutorial
6 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    BrianReeve
    wrote on last edited by
    #1

    I am looking how to measure the performance of the set.h file in the Standard Template Library. This is for a homework assignment. We are required to modify the set.h file with global integer variables to do the following: I need to know how to count the number of compares and data moves that take place when loading N number of strings into a set or multiset. I tried to open up the set.h and increment counters in a few places, but I have no idea which functions do what. The set.h file is very confusing to me. Any help is appreciated.

    S A J 3 Replies Last reply
    0
    • B BrianReeve

      I am looking how to measure the performance of the set.h file in the Standard Template Library. This is for a homework assignment. We are required to modify the set.h file with global integer variables to do the following: I need to know how to count the number of compares and data moves that take place when loading N number of strings into a set or multiset. I tried to open up the set.h and increment counters in a few places, but I have no idea which functions do what. The set.h file is very confusing to me. Any help is appreciated.

      S Offline
      S Offline
      Stefan Pedersen
      wrote on last edited by
      #2

      Why not use the contained object instead? Just overload constructors and the relevant operators. And if the paths that I have followed/have tread against the flow/there is no need for sorrow I am coming home Return, Crüxshadows

      1 Reply Last reply
      0
      • B BrianReeve

        I am looking how to measure the performance of the set.h file in the Standard Template Library. This is for a homework assignment. We are required to modify the set.h file with global integer variables to do the following: I need to know how to count the number of compares and data moves that take place when loading N number of strings into a set or multiset. I tried to open up the set.h and increment counters in a few places, but I have no idea which functions do what. The set.h file is very confusing to me. Any help is appreciated.

        A Offline
        A Offline
        Andreas Saurwein
        wrote on last edited by
        #3

        As they always say "kids, dont try this at home". Or better, dont try this with the set which shipped with VC6. Take the STLport (stlport.org[^]), its much more readable and is still a compatible implementation.


        Finally moved to Brazil

        B 1 Reply Last reply
        0
        • A Andreas Saurwein

          As they always say "kids, dont try this at home". Or better, dont try this with the set which shipped with VC6. Take the STLport (stlport.org[^]), its much more readable and is still a compatible implementation.


          Finally moved to Brazil

          B Offline
          B Offline
          BrianReeve
          wrote on last edited by
          #4

          I wasn't modifying the original set.h file. I made a copy an placed it in my project file. I simply linked to it absolutely. Thanks for the other resource tho! Is there a set.h (or similar header file) included in that implimentation? If it is more readable, it will definitely help. Thanks, Brian

          A 1 Reply Last reply
          0
          • B BrianReeve

            I wasn't modifying the original set.h file. I made a copy an placed it in my project file. I simply linked to it absolutely. Thanks for the other resource tho! Is there a set.h (or similar header file) included in that implimentation? If it is more readable, it will definitely help. Thanks, Brian

            A Offline
            A Offline
            Andreas Saurwein
            wrote on last edited by
            #5

            BrianReeve wrote: I wasn't modifying the original set.h file Actually I was referring to trying to understand not to modifying the file. BrianReeve wrote: Is there a set.h (or similar header file) included in that implimentation? You bet there is: <set>


            Finally moved to Brazil

            1 Reply Last reply
            0
            • B BrianReeve

              I am looking how to measure the performance of the set.h file in the Standard Template Library. This is for a homework assignment. We are required to modify the set.h file with global integer variables to do the following: I need to know how to count the number of compares and data moves that take place when loading N number of strings into a set or multiset. I tried to open up the set.h and increment counters in a few places, but I have no idea which functions do what. The set.h file is very confusing to me. Any help is appreciated.

              J Offline
              J Offline
              Joaquin M Lopez Munoz
              wrote on last edited by
              #6

              You can get these estimates without modifying the source code of std::set. In order to count copying and compare operations, enrich the class you're using as element in the set like follows:

              class element_set
              {
              public:
              static unsigned no_of_copying_ops;
              static unsigned no_of_compare_ops;

              element_set(const element_set& x)
              {
              ++unsigned no_of_copying_ops;
              ...
              }

              bool operator<(const element_set& x)const
              {
              ++no_of_compare_ops;
              ...
              }

              ...
              };

              unsigned element_set::no_of_copying_ops=0;
              unsigned element_set::no_of_compare_ops=0;

              Hope this helps, good luck. Joaquín M López Muñoz Telefónica, Investigación y Desarrollo

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups