in contribs/CekiGulcu/AppenderTable.java [66:122]
static public void main(String[] args) {
if(args.length != 2) {
System.err.println(
"Usage: java AppenderTable bufferSize runLength\n"
+" where bufferSize is the size of the cyclic buffer in the TableModel\n"
+" and runLength is the total number of elements to add to the table in\n"
+" this test run.");
return;
}
JFrame frame = new JFrame("JTableAppennder test");
Container container = frame.getContentPane();
AppenderTable tableAppender = new AppenderTable();
int bufferSize = Integer.parseInt(args[0]);
AppenderTableModel model = new AppenderTableModel(bufferSize);
tableAppender.setModel(model);
int runLength = Integer.parseInt(args[1]);
JScrollPane sp = new JScrollPane(tableAppender);
sp.setPreferredSize(new Dimension(250, 80));
container.setLayout(new BoxLayout(container, BoxLayout.X_AXIS));
container.add(sp);
// The "ADD" button is intended for manual testing. It will
// add one new logging event to the table.
JButton button = new JButton("ADD");
container.add(button);
button.addActionListener(new JTableAddAction(tableAppender));
frame.setSize(new Dimension(500,300));
frame.setVisible(true);
long before = System.currentTimeMillis();
int i = 0;
while(i++ < runLength) {
LoggingEvent event = new LoggingEvent("x", logger, Level.ERROR,
"Message "+i, null);
tableAppender.doAppend(event);
}
long after = System.currentTimeMillis();
long totalTime = (after-before);
System.out.println("Total time :"+totalTime+ " milliseconds for "+
"runLength insertions.");
System.out.println("Average time per insertion :"
+(totalTime*1000/runLength)+ " micro-seconds.");
}