Hansdampf
|
 |
«
Posted
2009-02-01 18:04:28 » |
|
I discovered the holy grail, the silver bullet that solves all performance problems. Some of you will be impressed, others will throw eggs at me for cheating. Post your sprite count when the demo starts lagging. http://www.emaggame.com/(top left button)
|
|
|
|
|
|
Riven
|
 |
«
Reply #2 - Posted
2009-02-01 18:48:41 » |
|
I let it run up to 205k, and it didn't show any performance degradation.
But... when I closed the browser tab, it totally crashed the browser... man, I hate the plugin.
|
|
|
|
Games published by our own members! Check 'em out!
|
|
pjt33
|
 |
«
Reply #3 - Posted
2009-02-01 20:12:39 » |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| timinginfo 138 ms, ready at 11.34 loading: textures textures.txt [kdk.textures.n] timinginfo 11545 ms, ready at 11.55 simpleinit() [kdk.aa] java.lang.ClassCastException: sun.awt.image.DataBufferNative cannot be cast to java.awt.image.DataBufferInt at kdk.bx.n(kAi:404) at kdk.bq.c(kAi:22) at kdk.bq.<init>(kAi:65) at kdk.ak.b(kAi:47) at kdk.dope.m.setSize(kAi:876) at kdk.dope.m.<init>(kAi:120) at kdk.dope.m.<init>(kAi:133) at kdk.dope.j.<init>(kAi:23) at kdk.aa.a(kAi:432) at kdk.bf.start(kAi:184) at sun.applet.AppletPanel.run(Unknown Source) at java.lang.Thread.run(Unknown Source) |
So I think that's 0. Additionally I had to kill the browser because it wasn't responding.
|
|
|
|
|
Bonbon-Chan
|
 |
«
Reply #4 - Posted
2009-02-01 21:22:16 » |
|
Windows Vista QuaCore Q6600 (2,4Ghz) NVidia 8800GT, Java 1.6.0_07-b06 Getting bored after 100 000  But the applet version didn't work at all... nothing in the consol... juste de java sun logo.
|
|
|
|
|
Hansdampf
|
 |
«
Reply #5 - Posted
2009-02-01 21:37:07 » |
|
Very strange... maybe the applet issues have something to do with parameters (-Djnlp.packEnabled=true) I pass there, or with some threads I spawn for parallel processing. I will remove both tomorrow. I know even less about that java.lang.ClassCastException: sun.awt.image.DataBufferNative cannot be cast to java.awt.image.DataBufferInt Exception. Is that Linux running some kind of open Java? Mrs Google could not help me.
|
|
|
|
Bonbon-Chan
|
 |
«
Reply #6 - Posted
2009-02-02 10:11:40 » |
|
You should put a FPS counter, it will be better to define when it's beging to slow down.
Windows XP, Celeron 2,4GHz, Intel 82865G, Java 1.6.0_07-b06 : - no problem with the applet - around 50 000, it seems to slow down a bit
|
|
|
|
|
Riven
|
 |
«
Reply #7 - Posted
2009-02-02 10:13:12 » |
|
It never seems to slowdown.
Must be a nice cheat.
|
|
|
|
princec
|
 |
«
Reply #8 - Posted
2009-02-02 10:18:58 » |
|
Hm doesn't actually look like 10,000 sprites to me... Cas 
|
|
|
|
erikd
|
 |
«
Reply #9 - Posted
2009-02-02 10:21:19 » |
|
I think the cheat is that it's just 5 sprites with about 3 backbuffers that are never cleared.
|
|
|
|
Games published by our own members! Check 'em out!
|
|
Hansdampf
|
 |
«
Reply #10 - Posted
2009-02-02 10:23:12 » |
|
yes, looks more like 1 billion sprites if you let it run for a week. here is the pseudocode: (slightly changed, I use rasters of BufferedImages and blit via loops) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
| Image pic; Image[] buf; int width=800,height=600; int count = 0;
public void init() { buf = new Image[10]; for (int i = 0; i < buf.length; i++) { buf[i] = new Image(width,height); } pic = somePicture(); }
public void render() { count++; getGraphics().drawImage(buf[count % buf.length],0,0,null); for (int i = 0; i < buf.length; i++) { float frak = (float) i / buf.length; float time = (count + frak) / (20f); int w=width/2; int h=height/2; int x=w+(int)(w/2*Math.sin(time)); int y=h+(int)(h/2*Math.sin(time*2.1)); buf[i].getGraphics().drawImage(pic, x, y, null); } } |
|
|
|
|
Hansdampf
|
 |
«
Reply #11 - Posted
2009-02-02 10:36:43 » |
|
You should put a FPS counter, it will be better to define when it's beging to slow down.
Windows XP, Celeron 2,4GHz, Intel 82865G, Java 1.6.0_07-b06 : - no problem with the applet - around 50 000, it seems to slow down a bit
Funny that the applet works now, I did NO update yet. Java is great. 
|
|
|
|
Markus_Persson
|
 |
«
Reply #12 - Posted
2009-02-02 10:54:34 » |
|
Yeah, it's an old trick. I'm a bit amazed people fall for it.  * Markus_Persson does some palette shifting tricks
|
|
|
|
Hansdampf
|
 |
«
Reply #13 - Posted
2009-02-02 10:57:33 » |
|
Yes, I expected more eggs and boo's 
|
|
|
|
Riven
|
 |
«
Reply #14 - Posted
2009-02-02 11:25:27 » |
|
getGraphics().drawImage(buf[count % buf.length],0,0,null);
Please call graphics.dispose() ! You're leaking native resources.
|
|
|
|
Hansdampf
|
 |
«
Reply #15 - Posted
2009-02-02 11:31:24 » |
|
getGraphics().drawImage(buf[count % buf.length],0,0,null);
Please call graphics.dispose() ! You're leaking native resources.
don't worry, that was meant as pseudocode. And there is the main function missing. And 42 more things.
|
|
|
|
Markus_Persson
|
 |
«
Reply #16 - Posted
2009-02-02 11:36:29 » |
|
You're leaking native resources. Well, not leaking.. When a Java program runs, a large number of Graphics objects can be created within a short time frame. Although the finalization process of the garbage collector also disposes of the same system resources, it is preferable to manually free the associated resources by calling this method rather than to rely on a finalization process which may not run to completion for a long period of time.
|
|
|
|
Bonbon-Chan
|
 |
«
Reply #17 - Posted
2009-02-02 12:03:24 » |
|
Funny that the applet works now, I did NO update yet. Java is great.  Not the same PC, not the same OS 
|
|
|
|
|
Riven
|
 |
«
Reply #18 - Posted
2009-02-02 12:09:52 » |
|
Well, not leaking..
Hmm... good to know, although in theory, you could run out of native resources before the GC is executed, as it doesn't grow the heap - but chances are slim.
|
|
|
|
Markus_Persson
|
 |
«
Reply #19 - Posted
2009-02-02 14:23:38 » |
|
Yeah, and it'll probably allocate more ram than needed if you don't dispose() as it has to wait for the gc.
|
|
|
|
h3ckboy
|
 |
«
Reply #20 - Posted
2009-02-02 15:00:04 » |
|
it jsut said something like game over over and over. and then IE freezes
|
|
|
|
|
Hansdampf
|
 |
«
Reply #21 - Posted
2009-02-02 15:50:06 » |
|
it jsut said something like game over over and over. and then IE freezes
wsa tath a g4me or teh 10.000 thign? 4nyway, I upd4ed ti nwo. I hope the applet problems came from usage of java.util.concurrent.ExecutorService, which I dropped now.
|
|
|
|
pjt33
|
 |
«
Reply #22 - Posted
2009-02-02 19:51:01 » |
|
Very strange... maybe the applet issues have something to do with parameters (-Djnlp.packEnabled=true) I pass there, or with some threads I spawn for parallel processing. I will remove both tomorrow. I know even less about that Exception. Is that Linux running some kind of open Java? Mrs Google could not help me.
Linux running Sun Java 1.6-u10-beta.
|
|
|
|
|
Hansdampf
|
 |
«
Reply #23 - Posted
2009-02-02 20:07:35 » |
|
Linux running Sun Java 1.6-u10-beta.
I think it works now, EgonOlsen had the same Exception. I think/guess/hope it works now.
|
|
|
|
pjt33
|
 |
«
Reply #24 - Posted
2009-02-03 10:44:02 » |
|
I think it works now, EgonOlsen had the same Exception. I think/guess/hope it works now.
I was able to run it from appletviewer. After last time I didn't want to risk running it in the browser.
|
|
|
|
|
|