Hi,
in my web app I have to refresh a table of 6 columns and around 50
rows to refresh 4 times a second with new data. I'm using CellTable
for that, since its performance is good, but when I do that, CPU usage
is at about 60%!
I know that rendering of the HTMl in the browser is expensive, but
that expensive? Is there any way how I can display the data using
CellTable? Any other idea?
Here is my test code:
public class Sandbox implements EntryPoint
{
public CellTable<Contact> table = null;
public ArrayList<Contact> list = new ArrayList<Contact>();
public void onModuleLoad()
{
// Create a CellTable.
table = new CellTable<Contact>();
table.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.ENABLED);
TextColumn<Contact> nameColumn = new TextColumn<Contact>() {
@Override
public String getValue(Contact object)
{
return object.name;
}
};
table.addColumn(nameColumn, "Name");
TextColumn<Contact> aColumn = new TextColumn<Contact>() {
@Override
public String getValue(Contact object)
{
return object.a + "";
}
};
table.addColumn(aColumn, "A");
TextColumn<Contact> bColumn = new TextColumn<Contact>() {
@Override
public String getValue(Contact object)
{
return object.b + "";
}
};
table.addColumn(bColumn, "B");
TextColumn<Contact> cColumn = new TextColumn<Contact>() {
@Override
public String getValue(Contact object)
{
return object.c + "";
}
};
table.addColumn(cColumn, "C");
TextColumn<Contact> dColumn = new TextColumn<Contact>() {
@Override
public String getValue(Contact object)
{
return object.d + "";
}
};
table.addColumn(dColumn, "D");
RootPanel.get().add(table);
Timer timer = new Timer()
{
public void run()
{
update();
}};
timer.scheduleRepeating(250);
}
private void update()
{
list.clear();
for(int i = 0; i < 50; i++)
{
list.add(new Contact("abc", Random.nextDouble(),
Random.nextDouble(), Random.nextDouble(), Random.nextDouble()));
}
table.setRowCount(list.size(), true);
table.setRowData(list);
}
}
class Contact
{
public final String name;
public final double a;
public final double b;
public final double c;
public final double d;
public Contact(String name, double a, double b, double c, double d)
{
this.name = name;
this.a = a;
this.b = b;
this.c = c;
this.d = d;
}
}
Thanks for any help on that.
Cheers
T
--
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-web-toolkit?hl=en.