W
Wizumwalt
I'm trying to cut down the time it takes to do the following task. It
currently takes about 25 seconds to do. If anyone has any tips on what
could cut this down considerably, any help much appreciated.
---
// elements is a hashmap of 10000 shapes containing 7100 Triangles.
...
for (Iterator iter = elements.values().iterator(); iter.hasNext()
{
Element elem = (Element)iter.next();
if (elem.getShape() == TRIANGLE) {
doStuff(elem);
}
}
public void doStuff(Element tri) {
for (int j = 0; j < 3; j++) {
// here I allocate a data structure using new for each triangle
edge
// has 4 set() methods to newly allocated data structure
}
doMoreStuff(NewDataStructures[] ds)
}
public void doMoreStuff(NewDataStructures[] ds) {
// this isn't included in method above because I have
// to have my 3 new data structures built first before
// I can set data to them.
for (int k = 0; k < 3; k++) {
// ds[k].set(...);
// has 3 set methods like above
}
}
I'm thinking the problem might be in the for statement using j where I
allocate a new data structure (class) for each edge of my triangle. Is
allocating a new object the slowest statement in this code?
currently takes about 25 seconds to do. If anyone has any tips on what
could cut this down considerably, any help much appreciated.
---
// elements is a hashmap of 10000 shapes containing 7100 Triangles.
...
for (Iterator iter = elements.values().iterator(); iter.hasNext()
{
Element elem = (Element)iter.next();
if (elem.getShape() == TRIANGLE) {
doStuff(elem);
}
}
public void doStuff(Element tri) {
for (int j = 0; j < 3; j++) {
// here I allocate a data structure using new for each triangle
edge
// has 4 set() methods to newly allocated data structure
}
doMoreStuff(NewDataStructures[] ds)
}
public void doMoreStuff(NewDataStructures[] ds) {
// this isn't included in method above because I have
// to have my 3 new data structures built first before
// I can set data to them.
for (int k = 0; k < 3; k++) {
// ds[k].set(...);
// has 3 set methods like above
}
}
I'm thinking the problem might be in the for statement using j where I
allocate a new data structure (class) for each edge of my triangle. Is
allocating a new object the slowest statement in this code?