mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
bug fixed & optimzed Histogram memory used
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
package com.alibaba.druid.stat;
|
||||
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.text.NumberFormat;
|
||||
|
||||
import com.alibaba.druid.util.Histogram;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
public class HistogramMemoryTest extends TestCase {
|
||||
|
||||
public void test_0() throws Exception {
|
||||
long memoryStart = ManagementFactory.getMemoryMXBean().getHeapMemoryUsage().getUsed();
|
||||
|
||||
final int COUNT = 1024 * 1;
|
||||
Object[] items = new Object[COUNT];
|
||||
for (int i = 0; i < COUNT; ++i) {
|
||||
// items[i] = new JdbcSqlStat("");
|
||||
items[i] = Histogram.makeHistogram(20);
|
||||
}
|
||||
|
||||
long memoryEnd = ManagementFactory.getMemoryMXBean().getHeapMemoryUsage().getUsed();
|
||||
|
||||
System.out.println("memory used : " + NumberFormat.getInstance().format(memoryEnd - memoryStart));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user