Your performance penalty is probably coming from the fact that you're allocating data on the heap within a loop that you want to execute fast. You should also avoid the stream I/O in the loop. That's another performance penalty. What is the source of the data? Try a different strategy. I.e, read all the input into some sort of buffer, then efficiently compute in one fell-swoop your memory requirements and allocate it all at once. Then, construct your data structures within the allocated memory region, and avoid the use of the 'new' operator if you can help it... This should speed things up a little. I don't know the context in which this code is executing, otherwise I could help you further. Feel free to e-mail. When's the deadline? Looking at "weights and vertexes", I am thinking you're trying to tackle some graph algorithm problem of sorts. What's the target platform? We can optimize this right down to the lowest level, after, of course, we optimize your algorithms too. First things first - save your current work, so you have a fall back if your optimization efforts fail. -- Pavan Tumati ([EMAIL PROTECTED]) http://www.students.uiuc.edu/~tumati Computer Engineering Student University of Illinois @ Urbana-Champaign Intel VP David House, In _EE_Times_, 16 October 1989: "Bill Gates says no matter how much more power we can supply, he'll develop some really exciting software that will bring the machine to its knees." On Thu, 7 Jun 2001, Chan Yan Huang wrote: > > this part running painfully slow. its correct but if i handin this i will > lose all the pts in cpu speed contest > that's about 30 % of program of my grade. open for suggestion it is > basically initialize a double pointer to > take input. but it is tooo ooo slow , my instructor sean give zero for > that. and i can't think any improvement > . help man !!!!!! > > istream & operator>> (istream &in, Grid &grid) > { > int x,edgesNum; > > int i = 0 ; > while (in >> x) > { > in >> edgesNum; //the number of edges 1-5 > grid.Vertices[x]->EdgeSize = edgesNum; > (grid.Vertices[x])->edges = new Edge *[edgesNum]; //2 nd edges is > while ( i<edgesNum) > { > grid.Vertices[x]->edges[i] = new Edge(); > in >> grid.Vertices[x]->edges[i]->ToVertax; > in >> grid.Vertices[x]->edges[i]->Weight; > grid.Vertices[x]->edges[i]->FromVertax = x; > i++; > } > > i = 0; > //might need a getline to go to next line for input > } > return in; > } // operator>> >
Re: [vox-tech] can you run it faster for my 110 program?
-/\\/\\/\\- (Mister Resistor) Fri, 08 Jun 2001 00:53:04 -0700
- RE: [vox-tech] can you run it faster for my ... -/\\/\\/\\- (Mister Resistor)
- RE: [vox-tech] can you run it faster fo... Chan Yan Huang
- Re: [vox-tech] can you run it faste... Peter Jay Salzman
- Re: [vox-tech] can you run it f... Joshua Poppe
- Re: [vox-tech] can you run it faster fo... Nicole Carlson
- Re: [vox-tech] can you run it faster fo... Peter Jay Salzman
- Re: [vox-tech] can you run it faste... Nicole Carlson
