~kiithsacmp/miniini/trunk

« back to all changes in this revision

Viewing changes to miniini/include/inisection.h

  • Committer: Ferdinand Majerech
  • Date: 2010-07-12 15:06:46 UTC
  • Revision ID: kiithsacmp@gmail.com-20100712150646-gp61bwuf2mdftr5m
Added detailed memory benchmarking measurements used with flag MINIINI_BENCH_EXTRA. Increased default allocator block count to from 16 to 32. Version-compare.py now uses make to compile compared versions, and has a new option, --no-stl, to disable STL benchmarks. Logging buffer size was decreased from 1024 to 768 bytes. INISection and allocator block classes are now smaller to save memory - using 32bit ints instead of fastest ints available on platform. This does not change peak memory usage much, but decreases INIFile data structure overhead measurably. Names of time extra benchmarking measurements used with MINIINI_BENCH_EXTRA were changed to improve consistency. Small bug fixed in the article about MiniINI data storage and in testutil-compare.py. Added a help() function to commit.py to print usage information.

Show diffs side-by-side

added added

removed removed

Lines of Context:
10
10
 
11
11
#include "typedefs.h"
12
12
#include "miniini_assert.h"
 
13
#include "globals.h"
13
14
#include "allocator.h"
14
15
#include "linetoken.h"
15
16
#ifndef MINIINI_NO_STL
29
30
        ///Name of the section. Read from section header.
30
31
        miniini_private::c * Name;
31
32
        ///Number of tags in the section.
32
 
        miniini_private::ui Length;
 
33
        miniini_private::u32 Length;
 
34
        ///Iteration index
 
35
        miniini_private::s32 Iter;
33
36
        /** Tags in the section.
34
37
         * Each tag is stored as a char buffer containing name, a trailing
35
38
         * zero, any number of values followed by trailing zeroes, with the
38
41
        miniini_private::c * * Tags;
39
42
        ///Allocator for strings in the section.
40
43
        miniini_private::Allocator * Alloc;
41
 
        ///Iteration index
42
 
        miniini_private::i Iter;
43
44
 
44
45
                              
45
 
        ///Data that doesn't need to be reinitialized in every constructor call.
 
46
        ///Buffers used in initialization that don't have to be reallocated with
 
47
        ///    every section.
46
48
        ///Temp tags buffer capacity.
47
49
        static miniini_private::ui temptagscap;
48
50
        ///Stores tags during loading.
92
94
         */
93
95
        bool Next()
94
96
        {
95
 
            if(Iter < static_cast<miniini_private::i>(Length) - 1)
 
97
            if(Iter < static_cast<miniini_private::s32>(Length) - 1)
96
98
            {
97
99
                ++Iter;
98
100
                return true;
104
106
         */
105
107
        const char * CurrentTag() const
106
108
        {
107
 
            MINIINI_ASSERT(Iter >= static_cast<miniini_private::i>(0) && 
108
 
                           Iter < static_cast<miniini_private::i>(Length), 
 
109
            MINIINI_ASSERT(Iter >= static_cast<miniini_private::s32>(0) && 
 
110
                           Iter < static_cast<miniini_private::s32>(Length), 
109
111
                           "Called INISection::CurrentTag() with iteration index "
110
112
                           "out of range");
111
113
            return Tags[Iter];
117
119
        #ifndef MINIINI_NO_STL
118
120
        std::string CurrentTagSTL() const
119
121
        {
120
 
            MINIINI_ASSERT(Iter >= static_cast<miniini_private::i>(0) && 
121
 
                           Iter < static_cast<miniini_private::i>(Length), 
 
122
            MINIINI_ASSERT(Iter >= static_cast<miniini_private::s32>(0) && 
 
123
                           Iter < static_cast<miniini_private::s32>(Length), 
122
124
                           "Called INISection::CurrentTagSTL() with iteration "
123
125
                           "index out of range");
124
126
            return std::string(Tags[Iter]);
440
442
                           std::vector<bool> & out) const;
441
443
        #endif
442
444
 
 
445
        #ifdef MINIINI_BENCH_EXTRA
 
446
        /** Determines memory usage of this INISection.
 
447
         * Writes to global variables used to measure memory usage.
 
448
         */
 
449
        void MemoryUsage() const
 
450
        {
 
451
            miniini_private::memory_tag_ptrs += Length * 
 
452
                                                sizeof(miniini_private::c *);
 
453
            miniini_private::memory_sections += sizeof(INISection);
 
454
        }
 
455
 
 
456
        /** Determines number of dynamically allocated buffers in the INISection.
 
457
         * @return number of dynamically allocated buffers.
 
458
         */
 
459
        miniini_private::ui MemoryDynamicBuffers() const
 
460
        {
 
461
            //Tags is the only buffer here (Name and tags themselves are in
 
462
            //Allocator)
 
463
            return 1;
 
464
        }
 
465
        
 
466
        #endif
 
467
 
443
468
    private:
444
469
 
445
470
        ///Empty constructor.
446
471
        INISection()
447
472
            :Name(NULL)
448
473
            ,Length(0)
 
474
            ,Iter(-1)
449
475
            ,Tags(NULL)
450
476
            ,Alloc(NULL)
451
 
            ,Iter(-1)
452
477
        {}
453
478
 
454
479
        ///Destructor.