forked from I2P_Developers/i2p.i2p
more efficient mem alloc & usage
This commit is contained in:
@@ -14,7 +14,7 @@ import java.io.ByteArrayOutputStream;
|
|||||||
import java.io.FilterInputStream;
|
import java.io.FilterInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.LinkedList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import net.i2p.I2PAppContext;
|
import net.i2p.I2PAppContext;
|
||||||
@@ -61,7 +61,7 @@ public class AESInputStream extends FilterInputStream {
|
|||||||
_lastBlock = new byte[BLOCK_SIZE];
|
_lastBlock = new byte[BLOCK_SIZE];
|
||||||
System.arraycopy(iv, 0, _lastBlock, 0, BLOCK_SIZE);
|
System.arraycopy(iv, 0, _lastBlock, 0, BLOCK_SIZE);
|
||||||
_encryptedBuf = new ByteArrayOutputStream(BLOCK_SIZE);
|
_encryptedBuf = new ByteArrayOutputStream(BLOCK_SIZE);
|
||||||
_readyBuf = new LinkedList();
|
_readyBuf = new ArrayList(1024);
|
||||||
_cumulativePaddingStripped = 0;
|
_cumulativePaddingStripped = 0;
|
||||||
_eofFound = false;
|
_eofFound = false;
|
||||||
}
|
}
|
||||||
|
@@ -349,8 +349,7 @@ public class Rate {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void store(OutputStream out, String prefix) throws IOException {
|
public void store(String prefix, StringBuffer buf) throws IOException {
|
||||||
StringBuffer buf = new StringBuffer(16*1048);
|
|
||||||
PersistenceHelper.add(buf, prefix, ".period", "Number of milliseconds in the period", _period);
|
PersistenceHelper.add(buf, prefix, ".period", "Number of milliseconds in the period", _period);
|
||||||
PersistenceHelper.add(buf, prefix, ".creationDate",
|
PersistenceHelper.add(buf, prefix, ".creationDate",
|
||||||
"When was this rate created? (milliseconds since the epoch, GMT)", _creationDate);
|
"When was this rate created? (milliseconds since the epoch, GMT)", _creationDate);
|
||||||
@@ -388,7 +387,6 @@ public class Rate {
|
|||||||
PersistenceHelper.add(buf, prefix, ".lifetimeTotalEventTime",
|
PersistenceHelper.add(buf, prefix, ".lifetimeTotalEventTime",
|
||||||
"How many milliseconds have the events since this stat was created consumed?",
|
"How many milliseconds have the events since this stat was created consumed?",
|
||||||
_lifetimeTotalEventTime);
|
_lifetimeTotalEventTime);
|
||||||
out.write(buf.toString().getBytes());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -476,11 +474,11 @@ public class Rate {
|
|||||||
rate.addData(i * 100, 20);
|
rate.addData(i * 100, 20);
|
||||||
}
|
}
|
||||||
rate.coallesce();
|
rate.coallesce();
|
||||||
java.io.ByteArrayOutputStream baos = new java.io.ByteArrayOutputStream(2048);
|
StringBuffer buf = new StringBuffer(1024);
|
||||||
try {
|
try {
|
||||||
rate.store(baos, "rate.test");
|
rate.store("rate.test", buf);
|
||||||
byte data[] = baos.toByteArray();
|
byte data[] = buf.toString().getBytes();
|
||||||
_log.error("Stored rate: size = " + data.length + "\n" + new String(data));
|
_log.error("Stored rate: size = " + data.length + "\n" + buf.toString());
|
||||||
|
|
||||||
Properties props = new Properties();
|
Properties props = new Properties();
|
||||||
props.load(new java.io.ByteArrayInputStream(data));
|
props.load(new java.io.ByteArrayInputStream(data));
|
||||||
|
@@ -110,16 +110,17 @@ public class RateStat {
|
|||||||
buf.append("# ").append(_description).append(NL);
|
buf.append("# ").append(_description).append(NL);
|
||||||
buf.append("# ").append(NL).append(NL);
|
buf.append("# ").append(NL).append(NL);
|
||||||
out.write(buf.toString().getBytes());
|
out.write(buf.toString().getBytes());
|
||||||
buf = null;
|
buf.setLength(0);
|
||||||
for (int i = 0; i < _rates.length; i++) {
|
for (int i = 0; i < _rates.length; i++) {
|
||||||
StringBuffer rbuf = new StringBuffer(1024);
|
buf.append("#######").append(NL);
|
||||||
rbuf.append("#######").append(NL);
|
buf.append("# Period : ").append(DataHelper.formatDuration(_rates[i].getPeriod())).append(" for rate ")
|
||||||
rbuf.append("# Period : ").append(DataHelper.formatDuration(_rates[i].getPeriod())).append(" for rate ")
|
|
||||||
.append(_groupName).append(" - ").append(_statName).append(NL);
|
.append(_groupName).append(" - ").append(_statName).append(NL);
|
||||||
rbuf.append(NL);
|
buf.append(NL);
|
||||||
out.write(rbuf.toString().getBytes());
|
out.write(buf.toString().getBytes());
|
||||||
String curPrefix = prefix + "." + DataHelper.formatDuration(_rates[i].getPeriod());
|
String curPrefix = prefix + "." + DataHelper.formatDuration(_rates[i].getPeriod());
|
||||||
_rates[i].store(out, curPrefix);
|
_rates[i].store(curPrefix, buf);
|
||||||
|
out.write(buf.toString().getBytes());
|
||||||
|
buf.setLength(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user