drone
YaBB Newbies
Offline
Posts: 7
erratic cpu ussage
Jun 18th , 2005, 5:29am
dont know if anyone else experiences this on their computers. Some sketches that I open will start running smoothly and then slowly the cpu ussage will escalate. I wrote a sketch were this happens. the sketch will start out smoothly and over a couple of minutes the cpu ussage will climb and the performance will drop, then it will drop back down and run smooth again for a couple of seconds then back up. the sketch I wrote shouldnt be doing anything different when its running smoothly than when its stuttering. any clues why this happens and any ways to get around it when I try it using P3D it stays at a steady stuttering speed, while OPENGL it goes from smooth to choppy. I also have framerate set to 30 to try to force it to stay steady but still nothing changes I was wondering if anyone else could try the sketch and let me know how it runs. I have a computer with a 3.2 processor 1gb of memory 128 vid card. just swept the computer for adware,spyware, and viruses, emptied internet files, closed unnessary processes, and the hard drive is defragged. but maybe Im missing something? this isnt the only sketch this happens to many other sketches that I write or find online exhibit this behaviour of beggingn running smoothly and a minute or so into it start to slow down. import processing.opengl.*; int step=20; int limit=30; int l=0; building[] buildings; void setup(){ size(800,600,OPENGL); framerate(30); buildings=new building[0]; builder(); fill(100,100,255); noStroke(); } void draw(){ background(0); //println(buildings.length); fill(80,80,80); beginShape(QUADS); vertex(-400,500,-800); vertex(1200,500,-800); vertex(1200,500,200); vertex(-400,500,200); endShape(); if(l<limit){ builder(); l++; } fill(100,100,250); for(int i=0; i<buildings.length; i++){ buildings[i].update(); } } void builder(){ int news=int(random(5,10)); news=8; building[] tmp=new building[buildings.length+news]; arraycopy(buildings,0,tmp,0,buildings.length); for(int i=buildings.length; i<(buildings.length+news); i++){ tmp[i]=new building(i); } buildings=tmp; } building[] remove(building[] array, int item) { building outgoing[] = new building[array.length - 1]; System.arraycopy(array, 0, outgoing, 0, (item)); System.arraycopy(array, item+1, outgoing, (item), (array.length-item-1)); return outgoing; } class building{ float x,y,z; int w,h,d,pos; building(int poss){ pos=poss; build(); } void build(){ //x=random(-400,1200); x=((pos*50)%1600)-400; y=500; //z=(random(-100,0))-700; z=-700; w=40;//int(random(10,70)); h=150;//int(random(10,150)); d=5;//int(random(10,70)); } void update(){ pushMatrix(); translate(x,y,z); box(w,h,d); popMatrix(); z+=step; if(z>100){ //for (int i=(pos+1); i<buildings.length; i++){ //buildings[i].pos-=1; //} //buildings=remove(buildings,pos); build(); } } } as far as this sketch goes I believe its drawing 328 box()'s on screen at once is that too much for processing to handle even in OPENGL. This sketch is mostly an experiment to see how much stuff I can get moving on screen at once to get an idea of it can handle for some future sketches im thinking of. thanks