Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (487)
Games in Android Showcase (112)
games submitted by our members
Games in WIP (553)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  The gremlins in my computer  (Read 1541 times)
0 Members and 1 Guest are viewing this topic.
Offline rouncer

Junior Member





« Posted 2010-05-02 13:52:02 »

I know being superstitious isnt what a programmer should be, but im a little that way when it comes to really strange bugs.
At the moment, my application suddenly stopped cycling quickly and started going with a really poor framerate... All I do is uncomment
this for loop and then all of sudden it starts going really slow.

all tiles have 0 astones so it shouldnt even be accessing the loops even though it somehow is, and the simple commented out for loop iterating
the v variable is enough to make it go slow for no reason.
I thought maybe it was because I had too much stuff in a single file, so I broke the program up to another file but it didnt make a difference, for
some reason its going slow and I have NO IDEA WHY.

As soon as I comment out the for loop it decides to go quick, and note ITS NOT RENDERING ANYTHING.

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  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
 for(i=0;i<btile[edit_tile].astones;i++)
   {
   if(btile[edit_tile].astone[i].enabled)
   {
     if(btile[edit_tile].astone[i].selected && fading_trim==false && fading_trim_depth==false && fading_depth==false)
     {
 //      eng.render(btile[edit_tile].astone[i].vs,btile[edit_tile].astone[i].v,btile[edit_tile].astone[i].ts,btile[edit_tile].astone[i].t,id,false, btile[edit_tile].astone[i].blight);    
    }
     else
     {
//     eng.render(btile[edit_tile].astone[i].vs,btile[edit_tile].astone[i].v,btile[edit_tile].astone[i].ts,btile[edit_tile].astone[i].t,id,true, btile[edit_tile].astone[i].blight);
    }    
   }
   }

   
   int v;
   for(v=0;v<8;v++)
   {
/*      
   switch(v)
   {
    case 0:trans.set_trans(-2, 0, 2);break;  
    case 1:trans.set_trans(0, 0, 2);break;  
    case 2:trans.set_trans(2, 0, 2);break;  
    case 3:trans.set_trans(-2, 0, 0);break;  
    case 4:trans.set_trans(2, 0, 0);break;  
    case 5:trans.set_trans(-2, 0, -2);break;  
    case 6:trans.set_trans(0, 0, -2);break;  
    case 7:trans.set_trans(2, 0, -2);break;  
   }

   for(i=0;i<btile[view_tile[v]].astones;i++)
    {
    if(btile[view_tile[v]].astone[i].enabled)
    {
     // eng.render(btile[view_tile[v]].astone[i].vs,btile[view_tile[v]].astone[i].v,btile[view_tile[v]].astone[i].ts,btile[view_tile[v]].astone[i].t,trans,true, btile[view_tile[v]].astone[i].blight);
     }
     
    }
*/

   }
   
Offline rouncer

Junior Member





« Reply #1 - Posted 2010-05-02 14:58:18 »

Its not because im using too much ram, because I checked that... anyone can help me with this really strange problem, like, can anything else you know of could slow a program down for virtually no reason?
Offline rouncer

Junior Member





« Reply #2 - Posted 2010-05-02 15:13:06 »

Ive in fact mucked around with it more, and I got it working from commenting out completely safe code thats not doing any work at all just returning false and not even chaining to it and it still triggers off the slowness!!!  what could be the problem?!?!?
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Wildern

Junior Member





« Reply #3 - Posted 2010-05-02 15:19:21 »

I would print out what is in btile[edit_tile].astone just to be sure it is what you think it is.
Offline rouncer

Junior Member





« Reply #4 - Posted 2010-05-02 15:41:11 »

Its strange, I got it going quick again by commenting out code, then all I did was add more code that I didnt even call and it went slow again.

Maybe I should try changing editors, whats another editor like Eclipse out there?  Ill try and install it...  thanks if anyone can help me.

I REALLY want this program to work... Its my next big thing if I can finish it, and I feel like throwing the computer out the friggin window!
Offline rouncer

Junior Member





« Reply #5 - Posted 2010-05-02 15:48:04 »

You wouldnt believe it, now ive added more code ive just commented the WHOLE thing out and now its going slow and im doing nothing.
Offline rouncer

Junior Member





« Reply #6 - Posted 2010-05-02 19:06:31 »

Ive even tested multiple IDE's now, and both have the same output, slowness - what the hell could be going wrong dammit!
Offline Riven
« League of Dukes »

JGO Overlord


Medals: 783
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #7 - Posted 2010-05-02 19:08:55 »

Define fast.
Define slow.

50 vs. 45 frames per second?
500 vs. 3 frames per second?

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline rouncer

Junior Member





« Reply #8 - Posted 2010-05-02 19:15:41 »

Dropped from 60 to about 5.

GUESS WHAT THE HELL IT WAS!!

I had too much code in the "run" function for my applet, All I did was drop some code into a function and it restored the speed.

Have you ever heard of that before anyone?!?  Thanks Riven anyway.
Offline Riven
« League of Dukes »

JGO Overlord


Medals: 783
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #9 - Posted 2010-05-02 19:21:36 »

Well, HotSpot (the Java Just-in-Time compiler) gives up most optimizations on MASSIVE methods. Hundreds of lines.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline rouncer

Junior Member





« Reply #10 - Posted 2010-05-02 19:22:20 »

So it doesnt even sound suprising to you, im learning lots me, gosh.
Offline Riven
« League of Dukes »

JGO Overlord


Medals: 783
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #11 - Posted 2010-05-02 19:31:14 »

Keep in mind that the java compiler (sourcecode=>bytecode) is doing little to no optimization. Every optimization is performed at runtime. Just compare how long a C compiler can take to compile an entire project (minutes / hours) and how long it takes in Java (seconds, if that... Eclipse is continually compiling every character typed, making compilation time almost zero seconds).

Now in those few seconds the HotSpot JIT compiler is analyzing your code at runtime, it approaches (on average) 90% of the performance the best C compiler achieves.

Give that fact, it's understandable that the HotSpot JIT tends to give up earlier on 'too complex code', as it would make the application stutter.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline rouncer

Junior Member





« Reply #12 - Posted 2010-05-02 19:44:16 »

Cool.

Im just glad I didnt give up and worked out the problem, cause my little program was going great until this happened, now I can keep developing it. Grin
Offline cylab

JGO Ninja


Medals: 43



« Reply #13 - Posted 2010-05-03 09:38:46 »

Despite of this more uncommon problem (most java devs have methods < 50 lines in 98% of the cases), you should make yourself familiar with a profiler. You get one for free build in, if you use Netbeans, which is more or less the same like Visual VM, that you can run standalone.

Mathias - I Know What [you] Did Last Summer!
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

TehJavaDev (13 views)
2014-08-28 18:26:30

CopyableCougar4 (25 views)
2014-08-22 19:31:30

atombrot (38 views)
2014-08-19 09:29:53

Tekkerue (31 views)
2014-08-16 06:45:27

Tekkerue (32 views)
2014-08-16 06:22:17

Tekkerue (19 views)
2014-08-16 06:20:21

Tekkerue (29 views)
2014-08-16 06:12:11

Rayexar (66 views)
2014-08-11 02:49:23

BurntPizza (42 views)
2014-08-09 21:09:32

BurntPizza (34 views)
2014-08-08 02:01:56
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!