Changeset 23c30a9


Ignore:
Timestamp:
Jul 21, 2011 1:06:59 PM (9 years ago)
Author:
dev <dev@…>
Branches:
master
Children:
661325a, a731c890
Parents:
7c4f088
Message:

Changed all iterators using entrySet() to values().
Removed debug from main()
Recommented main out.

File:
1 edited

Legend:

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

    r7c4f088 r23c30a9  
    4343    public void addData(long value, long eventDuration) {
    4444        if (_statLog != null) _statLog.addData(_groupName, _statName, value, eventDuration);
    45         for (Entry<Long, Rate> e: _rates.entrySet())
    46             e.getValue().addData(value, eventDuration);
     45        for (Rate r: _rates.values())
     46            r.addData(value, eventDuration);
    4747    }
    4848
    4949    /** coalesce all the stats */
    5050    public void coalesceStats() {
    51         for (Entry<Long, Rate> e: _rates.entrySet()){
    52             e.getValue().coalesce();
     51        for (Rate r: _rates.values()){
     52            r.coalesce();
    5353        }
    5454    }
     
    6969        long rv[] = new long[_rates.size()];
    7070        int counter = 0;
    71         for (Entry<Long, Rate> e: _rates.entrySet())
    72             rv[counter++] = e.getValue().getPeriod();
     71        for (Rate r: _rates.values())
     72            rv[counter++] = r.getPeriod();
    7373        Arrays.sort(rv);
    7474        return rv;
     
    7777    public double getLifetimeAverageValue() {
    7878        if ( (_rates == null) || (_rates.size() <= 0) ) return 0;
    79         return _rates.entrySet().iterator().next().getValue().getLifetimeAverageValue();
     79        return _rates.values().iterator().next().getLifetimeAverageValue();
    8080    }
    8181    public long getLifetimeEventCount() {
    8282        if ( (_rates == null) || (_rates.size() <= 0) ) return 0;
    83         return _rates.entrySet().iterator().next().getValue().getLifetimeEventCount();
     83        return _rates.values().iterator().next().getLifetimeEventCount();
    8484    }
    8585
     
    203203     */
    204204    public void load(Properties props, String prefix, boolean treatAsCurrent) throws IllegalArgumentException {
    205         for (Entry<Long, Rate> e: _rates.entrySet()) {
    206             long period = e.getValue().getPeriod();
     205        for (Rate r : _rates.values()) {
     206            long period = r.getPeriod();
    207207            String curPrefix = prefix + "." + DataHelper.formatDuration(period);
    208208            try {
    209                 e.getValue().load(props, curPrefix, treatAsCurrent);
     209                r.load(props, curPrefix, treatAsCurrent);
    210210            } catch (IllegalArgumentException iae) {
    211211                Rate rate = new Rate(period);
     
    219219
    220220/*********
    221 */
    222221    public static void main(String args[]) {
    223222        RateStat rs = new RateStat("moo", "moo moo moo", "cow trueisms", new long[] { 60 * 1000, 60 * 60 * 1000,
    224223                                                                                     24 * 60 * 60 * 1000});
    225        
    226         rs.getRate(5500L);
    227         System.out.println("Adding data..");
     224
    228225        for (int i = 0; i < 500; i++) {
    229226            try {
     
    234231        }
    235232       
    236         Rate rate5500 = rs.getRate(5500L);
    237         System.out.println("Nbr of events: " + rate5500.getCurrentEventCount());
    238         System.out.println("Average :" + rate5500.getAverageValue());
    239        
    240         System.out.println("Coalescing stats..");
    241233        rs.coalesceStats();
    242         System.out.println("Average :" + rate5500.getAverageValue());
    243         System.out.println("Coalescing this rate..");
    244         rate5500.coalesce();
    245         System.out.println("Average :" + rate5500.getAverageValue());
    246         System.out.println("Lifetime average :" + rate5500.getLifetimeAverageValue());
    247234
    248235        java.io.ByteArrayOutputStream baos = new java.io.ByteArrayOutputStream(2048);
     
    271258        }
    272259    }
    273  /**
    274260*********/
    275261}
Note: See TracChangeset for help on using the changeset viewer.