~michael-rynn-500/d2-xml/d2-xml-dev

« back to all changes in this revision

Viewing changes to alt/gcstats.d

  • Committer: ~michael~rynn~500
  • Date: 2013-04-20 09:24:20 UTC
  • Revision ID: michael.rynn.500@gmail.com-20130420092420-prin60y6261pk0qp
interim changes

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
module alt.gcstats;
2
 
        
 
2
 
3
3
/**
4
4
        Mixin to be added. Assumes no other default constructor, and not added at other places in inheritance.
5
5
        Other constructors may need tweeking. Implementation can be made more sophisticated.
14
14
        ulong sDeleted;
15
15
 
16
16
        __gshared GCStatsSum[] gAllStats;
17
 
        
 
17
 
18
18
        this()
19
19
        {
20
20
                gAllStats ~= this;
25
25
                sCreated++;
26
26
        }
27
27
    void dec()
28
 
        {       
 
28
        {
29
29
                sDeleted++;
30
30
        }
31
31
    void stats(ref ulong created, ref ulong deleted) const
51
51
        static bool statsLess(GCStatsSum a, GCStatsSum b)
52
52
        {
53
53
                auto adiff = a.sCreated - a.sDeleted;
54
 
                auto bdiff = b.sCreated - b.sDeleted;           
 
54
                auto bdiff = b.sCreated - b.sDeleted;
55
55
                return (adiff < bdiff) ? true : false;
56
56
        }
57
57
 
80
80
mixin template GC_statistics()
81
81
{
82
82
        static GCStatsSum       gcStatsSum;
83
 
        
 
83
 
84
84
        static this()
85
85
        {
86
86
                gcStatsSum = new GCStatsSum();
93
93
 
94
94
        /**
95
95
        In objects that use GC_STATS, require in this
 
96
    version(GC_STATS)
 
97
        {
 
98
                mixin GC_statistics;
 
99
                static this()
 
100
                {
 
101
                        setStatsId(typeid(typeof(this)).toString());
 
102
                }
 
103
        }
 
104
 
96
105
        ---
97
106
        this()
98
107
        {
112
121
                gcStatsSum.stats(created,deleted);
113
122
        }
114
123
 
115
 
}
 
 
b'\\ No newline at end of file'
 
124
}