Changeset ca4642e


Ignore:
Timestamp:
Nov 6, 2015 8:19:43 PM (5 years ago)
Author:
zab2 <zab2@…>
Branches:
master
Children:
7175b1c
Parents:
6bb156a4
Message:

Reduce the memory footprint of Rate objects by changing longs to ints and doubles to floats

File:
1 edited

Legend:

Unmodified
Added
Removed
  • core/java/src/net/i2p/stat/Rate.java

    r6bb156a4 rca4642e  
    1515public class Rate {
    1616    //private final static Log _log = new Log(Rate.class);
    17     private double _currentTotalValue;
     17    private float _currentTotalValue;
    1818    // was long, save space
    1919    private int _currentEventCount;
    20     private long _currentTotalEventTime;
    21     private double _lastTotalValue;
     20    private int _currentTotalEventTime;
     21    private float _lastTotalValue;
    2222    // was long, save space
    2323    private int _lastEventCount;
    24     private long _lastTotalEventTime;
    25     private double _extremeTotalValue;
     24    private int _lastTotalEventTime;
     25    private float _extremeTotalValue;
    2626    // was long, save space
    2727    private int _extremeEventCount;
    28     private long _extremeTotalEventTime;
    29     private double _lifetimeTotalValue;
     28    private int _extremeTotalEventTime;
     29    private float _lifetimeTotalValue;
    3030    private long _lifetimeEventCount;
    3131    private long _lifetimeTotalEventTime;
     
    228228
    229229            // how much were we off by?  (so that we can sample down the measured values)
    230             double periodFactor = measuredPeriod / (double)_period;
     230            float periodFactor = measuredPeriod / (float)_period;
    231231            _lastTotalValue = _currentTotalValue / periodFactor;
    232232            _lastEventCount = (int) (0.499999 + (_currentEventCount / periodFactor));
    233             _lastTotalEventTime = (long) (_currentTotalEventTime / periodFactor);
     233            _lastTotalEventTime = (int) (_currentTotalEventTime / periodFactor);
    234234            _lastCoalesceDate = now;
    235235            if (_currentEventCount == 0)
     
    245245            }
    246246
    247             _currentTotalValue = 0.0D;
     247            _currentTotalValue = 0.0f;
    248248            _currentEventCount = 0;
    249249            _currentTotalEventTime = 0;
     
    506506        _creationDate = PersistenceHelper.getLong(props, prefix, ".creationDate");
    507507        _lastCoalesceDate = PersistenceHelper.getLong(props, prefix, ".lastCoalesceDate");
    508         _currentTotalValue = PersistenceHelper.getDouble(props, prefix, ".currentTotalValue");
     508        _currentTotalValue = (float)PersistenceHelper.getDouble(props, prefix, ".currentTotalValue");
    509509        _currentEventCount = PersistenceHelper.getInt(props, prefix, ".currentEventCount");
    510         _currentTotalEventTime = PersistenceHelper.getLong(props, prefix, ".currentTotalEventTime");
    511         _lastTotalValue = PersistenceHelper.getDouble(props, prefix, ".lastTotalValue");
     510        _currentTotalEventTime = (int)PersistenceHelper.getLong(props, prefix, ".currentTotalEventTime");
     511        _lastTotalValue = (float)PersistenceHelper.getDouble(props, prefix, ".lastTotalValue");
    512512        _lastEventCount = PersistenceHelper.getInt(props, prefix, ".lastEventCount");
    513         _lastTotalEventTime = PersistenceHelper.getLong(props, prefix, ".lastTotalEventTime");
    514         _extremeTotalValue = PersistenceHelper.getDouble(props, prefix, ".extremeTotalValue");
     513        _lastTotalEventTime = (int)PersistenceHelper.getLong(props, prefix, ".lastTotalEventTime");
     514        _extremeTotalValue = (float)PersistenceHelper.getDouble(props, prefix, ".extremeTotalValue");
    515515        _extremeEventCount = PersistenceHelper.getInt(props, prefix, ".extremeEventCount");
    516         _extremeTotalEventTime = PersistenceHelper.getLong(props, prefix, ".extremeTotalEventTime");
    517         _lifetimeTotalValue = PersistenceHelper.getDouble(props, prefix, ".lifetimeTotalValue");
     516        _extremeTotalEventTime = (int)PersistenceHelper.getLong(props, prefix, ".extremeTotalEventTime");
     517        _lifetimeTotalValue = (float)PersistenceHelper.getDouble(props, prefix, ".lifetimeTotalValue");
    518518        _lifetimeEventCount = PersistenceHelper.getLong(props, prefix, ".lifetimeEventCount");
    519519        _lifetimeTotalEventTime = PersistenceHelper.getLong(props, prefix, ".lifetimeTotalEventTime");
Note: See TracChangeset for help on using the changeset viewer.