Changeset e6f610a


Ignore:
Timestamp:
Jun 25, 2004 5:20:08 PM (17 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
a019399
Parents:
7ef528b
git-author:
jrandom <jrandom> (06/25/04 17:20:08)
git-committer:
zzz <zzz@…> (06/25/04 17:20:08)
Message:

dont synchronize on statics, instead use a seperate format object per context (so large sims dont get bogged down on synchronization)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • router/java/src/net/i2p/router/StatisticsManager.java

    r7ef528b re6f610a  
    3434    public final static String PROP_MAX_PUBLISHED_PEERS = "router.publishPeerMax";
    3535    public final static int DEFAULT_MAX_PUBLISHED_PEERS = 20;
    36    
     36
     37    private final DecimalFormat _fmt;
     38    private final DecimalFormat _pct;
     39
    3740    public StatisticsManager(RouterContext context) {
    3841        _context = context;
     42        _fmt = new DecimalFormat("###,##0.00", new DecimalFormatSymbols(Locale.UK));
     43        _pct = new DecimalFormat("#0.00%", new DecimalFormatSymbols(Locale.UK));
    3944        _log = context.logManager().getLog(StatisticsManager.class);
    4045        _includePeerRankings = false;
     
    173178    }
    174179   
    175     private static String renderRate(Rate rate, boolean fudgeQuantity) {
     180    private String renderRate(Rate rate, boolean fudgeQuantity) {
    176181        StringBuffer buf = new StringBuffer(128);
    177182        buf.append(num(rate.getAverageValue())).append(';');
     
    247252
    248253   
    249     private static String getPeriod(Rate rate) { return DataHelper.formatDuration(rate.getPeriod()); }
    250 
    251     // TODO: get this to use some random locale, not the user's default (since its published)
    252     private final static DecimalFormat _fmt = new DecimalFormat("###,##0.00", new DecimalFormatSymbols(Locale.UK));
    253     private final static String num(double num) { synchronized (_fmt) { return _fmt.format(num); } }
    254    
    255     private final static DecimalFormat _pct = new DecimalFormat("#0.00%", new DecimalFormatSymbols(Locale.UK));
    256     private final static String pct(double num) { synchronized (_pct) { return _pct.format(num); } }
     254    private String getPeriod(Rate rate) { return DataHelper.formatDuration(rate.getPeriod()); }
     255
     256    private final String num(double num) { synchronized (_fmt) { return _fmt.format(num); } }
     257    private final String pct(double num) { synchronized (_pct) { return _pct.format(num); } }
    257258   
    258259    public String renderStatusHTML() { return ""; }
Note: See TracChangeset for help on using the changeset viewer.