Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (516)
Games in Android Showcase (123)
games submitted by our members
Games in WIP (577)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: 1 [2]
  ignore  |  Print  
  Let's do this.  (Read 6031 times)
0 Members and 1 Guest are viewing this topic.
Offline f.l.x

Senior Duke


Projects: 3


there is no place like 127.0.0.1


« Reply #30 - Posted 2005-12-06 23:29:01 »

ok more strange things (at least for me)

several line statements like:
1  
2  
3  
double _jy = (getHeight() / 2 
             - ((getHeight() / 2 - (FIELD_Y + FIELD_H)) * df))
             / e.getY() - df;


seems to add a couple of bytes to what this would produce:
1  
double _jy = (getHeight() / 2 - ((getHeight() / 2 - (FIELD_Y + FIELD_H)) * df)) / e.getY() - df;


All these are new things for me, i'm learning a lot with this contest, but i don't know what are true or what are just the affairs of the pixie that lives inside my pc.

Litterarum radices amaras, fructus dulces
http://flx.proyectoanonimo.com
figth spam!
Offline Morre

JGO Knight


Medals: 2
Projects: 10


I'm Dragonene on IRC.


« Reply #31 - Posted 2005-12-06 23:33:11 »

I assume there's no difference after compiling between the different casting types for simple data types? (float)1 and 1F, for example? Just curious :>

Offline Anon666

Junior Duke




aka Abuse/AbU5e/TehJumpingJawa


« Reply #32 - Posted 2005-12-06 23:41:20 »

hmmm

i have made some test on that  long constants optimizing

Mi early state game with this:

df = (int)((getWidth() / 2) / Math.tan(Math.PI / 4));

jared  3918b

with this
df = (int)((getWidth() / 2) / (float)Math.tan(Math.PI / 4));

3920b

but, it's not significative, i have been noticing something very strange:

before doing nothing to the code: 3920b
after adding a new blank line 3916b

 Undecided

the actual size of the bytecode can be affected simply by recompiling??!!


The bit you want to be casting in that expression is the ((float)Math.PI)/2.

When performing micro-optimisations I don't find it useful comparing the compressed jar size, as you cannot feasably measure the results of your change.

Simply try and reduce your compiled class size by as much as possible, (so the information being stored has reduced - atleast giving the potencial for the jar to get smaller)
while also considering any potencial reduction in the size of the symbol set used in the file. (to aid the compression algorithm)
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Anon666

Junior Duke




aka Abuse/AbU5e/TehJumpingJawa


« Reply #33 - Posted 2005-12-06 23:43:14 »

ok more strange things (at least for me)

several line statements like:
1  
2  
3  
double _jy = (getHeight() / 2 
             - ((getHeight() / 2 - (FIELD_Y + FIELD_H)) * df))
             / e.getY() - df;


seems to add a couple of bytes to what this would produce:
1  
double _jy = (getHeight() / 2 - ((getHeight() / 2 - (FIELD_Y + FIELD_H)) * df)) / e.getY() - df;


All these are new things for me, i'm learning a lot with this contest, but i don't know what are true or what are just the affairs of the pixie that lives inside my pc.

The only difference that could have on the resultant class file size, is that the debug information would be larger.
You should be compiling with debug off. (though passing the classes through any kind of obfuscator would also remove this information)

With debug off, white space has *zero* impact of the resultant binary size.
Offline f.l.x

Senior Duke


Projects: 3


there is no place like 127.0.0.1


« Reply #34 - Posted 2005-12-06 23:51:16 »

thanks Smiley that clarifies it a lot

Litterarum radices amaras, fructus dulces
http://flx.proyectoanonimo.com
figth spam!
Offline Anon666

Junior Duke




aka Abuse/AbU5e/TehJumpingJawa


« Reply #35 - Posted 2005-12-07 00:06:43 »

I assume there's no difference after compiling between the different casting types for simple data types? (float)1 and 1F, for example? Just curious :>

Compiling with javac, no, both of those expressions would be resolved to the same bytecode.

However from a bytecode perspective they are different.

Example 1:

(float)1 occupies 2bytes :-

1  
2  
iconst_1 //push the integer constant 1 onto the stack
i2f            //converts the integer on the top of the stack to a float


1F occupies just 1byte :-

1  
fconst_1 // push the float constant 1.0f onto the stack.


Javac would always evaluate both expressions to the second bytecode sequence - which is optimal.

However - if the value '1' was replaced with the value '5', things become a little different.

Example 2:

(float)5 still occupies 2 bytes :-

1  
2  
iconst_5 // push the constant 5 onto the stack
i2f            // cast it to a float.


however, 5F occupies a total of 4+2 bytes! :-

1  
2  
3  
4  
constants pool Entry:
[1] = 5.0f (4bytes)

ldc 1// load constant 1 onto the stack


In this instance, Javac would again generate bytecode that matched the second case.
However in this case, it is clearly not size-optimal.

The reason for the difference, is the bytecode instruction set contains 6 single bytecode instructions for pushing the integer constants (-1 through to +5) onto the stack,
where-as it has only 3  single bytecode instructions for pushing float constants (0 through to +2) onto the stack.

Incidentally, this is a good site for a clear overview of the instruction set:

http://homepages.inf.ed.ac.uk/kwxm/JVM/codeByNo.html
Pages: 1 [2]
  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 (33 views)
2014-10-27 03:28:38

TehJavaDev (26 views)
2014-10-27 03:27:51

DarkCart (41 views)
2014-10-26 19:37:11

Luminem (22 views)
2014-10-26 10:17:50

Luminem (27 views)
2014-10-26 10:14:04

theagentd (33 views)
2014-10-25 15:46:29

Longarmx (61 views)
2014-10-17 03:59:02

Norakomi (58 views)
2014-10-16 15:22:06

Norakomi (47 views)
2014-10-16 15:20:20

lcass (43 views)
2014-10-15 16:18:58
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

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
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!