lazyCreateChild(t, 0, 50);
return t;
}
protected Widget profileTree() {
final FlexTable table = new FlexTable();
final TextBox branches = new TextBox();
int row = 0;
table.setText(row, 0, "children per node");
table.setText(row, 1, "total number of rows");
table.setText(row, 2, "what type of node");
++row;
table.setWidget(row, 0, branches);
branches.setText("5");
final TextBox nodes = new TextBox();
table.setWidget(row, 1, nodes);
nodes.setText("2000");
table.setTitle("Number of nodes");
final ListBox type = new ListBox();
type.addItem("Text");
type.addItem("HTML");
type.addItem("CheckBox");
type.setSelectedIndex(1);
table.setWidget(row, 2, type);
++row;
final int widgetRow = row + 1;
table.setWidget(row, 0, new Button("Normal tree", new ClickListener() {
public void onClick(Widget sender) {
long time = System.currentTimeMillis();
Tree t = new Tree();
profileCreateTree(t, Integer.parseInt(branches.getText()),
Integer.parseInt(nodes.getText()),
TreeType.getType(type.getSelectedIndex()));
table.setWidget(widgetRow, 0, t);
Window.alert("Elapsed time: " + (System.currentTimeMillis() - time));
}
}));
table.setWidget(row, 1, new Button("Fast tree", new ClickListener() {
public void onClick(Widget sender) {
long time = System.currentTimeMillis();
FastTree t = new FastTree();
profileCreateTree(t, Integer.parseInt(branches.getText()),
Integer.parseInt(nodes.getText()),
TreeType.getType(type.getSelectedIndex()));
table.setWidget(widgetRow, 1, t);
Window.alert("Elapsed time: " + (System.currentTimeMillis() - time));
}
}));
++row;
table.setText(row, 0, "tree results");
table.getCellFormatter().setVerticalAlignment(row, 0,
HasAlignment.ALIGN_TOP);
table.setText(row, 1, "fasttree results");
table.getCellFormatter().setVerticalAlignment(row, 1,
HasAlignment.ALIGN_TOP);
return table;
}