Thread: Just a thought

Page 1 of 2 12 LastLast
Results 1 to 10 of 11
  1. #1 Just a thought 
    🍕

    Linus's Avatar
    Join Date
    Dec 2008
    Age
    31
    Posts
    2,779
    Thanks given
    974
    Thanks received
    411
    Rep Power
    0
    Why use for ints for example, "isDonator". Cause most servers just use isDonator == 1,
    When you can use a boolean? Which is faster to load?

    meaning if(isDonator) or if(!isDonator) compared to if(isDonator == 1) && if(isDonator == 0).

    I cant seem to find any information on the web about this.


    Reprogramming my player saving to be as efficient as possible.

    ╠╬╣
    ╦╦
    ╠╬╬╬╣
    ╠╬╬╬╬╬╬╣
    ╠╬╬╬╬╬╬╣
    ╚╩╩╩╩╩╩╝

    ╠╬╬╬╣



    Reply With Quote  
     

  2. #2  
    MOD DESIGNER RM MORE COMING


    TheeRash's Avatar
    Join Date
    Dec 2010
    Age
    30
    Posts
    5,128
    Thanks given
    639
    Thanks received
    2,123
    Rep Power
    5000
    Some people have different levels of donator, sooooooooooooooooooooooooooooooooooooooooooooooooo oooooooooo..


    Feel free to message me with any questions you may have - any offers of work will not be considered unless details are in the subject.
    Attached imageAttached imageAttached image
    Reply With Quote  
     

  3. #3  
    🍕

    Linus's Avatar
    Join Date
    Dec 2008
    Age
    31
    Posts
    2,779
    Thanks given
    974
    Thanks received
    411
    Rep Power
    0
    Quote Originally Posted by Thee Rash View Post
    Some people have different levels of donator, sooooooooooooooooooooooooooooooooooooooooooooooooo oooooooooo..
    it was just an example, durr

    ╠╬╣
    ╦╦
    ╠╬╬╬╣
    ╠╬╬╬╬╬╬╣
    ╠╬╬╬╬╬╬╣
    ╚╩╩╩╩╩╩╝

    ╠╬╬╬╣



    Reply With Quote  
     

  4. #4  
    Registered Member

    Join Date
    Oct 2007
    Posts
    1,063
    Thanks given
    155
    Thanks received
    162
    Rep Power
    286
    You'll feel absolutely no difference when changing that.

    I'm even unsure if it'd technically really be a difference. A boolean could be interpreted
    as integer for faster calculating operations...
    Reply With Quote  
     

  5. Thankful user:


  6. #5  
    Super Donator

    Benji's Avatar
    Join Date
    Feb 2010
    Age
    29
    Posts
    1,525
    Thanks given
    920
    Thanks received
    503
    Rep Power
    570
    Boolean evaluating is probably faster (by like what, tiny fraction of a nano?) than evaluating an integer value, but you're basically picking for specks of dust on the body of a dying man if you're really serious about doing that for performance lmfao

    Reply With Quote  
     

  7. #6  
    Respected Member


    Join Date
    Jan 2009
    Posts
    5,743
    Thanks given
    1,162
    Thanks received
    3,603
    Rep Power
    5000
    Quote Originally Posted by Benjii View Post
    Boolean evaluating is probably faster (by like what, tiny fraction of a nano?) than evaluating an integer value, but you're basically picking for specks of dust on the body of a dying man if you're really serious about doing that for performance lmfao
    There would be no difference in speed, however memory would be a very small difference from 4 bytes to just the 1.

    You could also use a short which is just 2 bytes, if you are really into that sort of thing. Would most likely find yourself casting to an integer later though anyway... The only real time you would worry about this is when using 1000's of objects, for example the player object, hence why servers are finally converting constants etc rather then spawning new ones per player object spawned.
    Reply With Quote  
     

  8. Thankful user:


  9. #7  
    PokeNation! Xaves's Avatar
    Join Date
    Dec 2007
    Age
    32
    Posts
    3,476
    Thanks given
    356
    Thanks received
    788
    Rep Power
    646
    Quote Originally Posted by 317x View Post
    There would be no difference in speed, however memory would be a very small difference from 4 bytes to just the 1.

    You could also use a short which is just 2 bytes, if you are really into that sort of thing. Would most likely find yourself casting to an integer later though anyway...
    Or a byte since he probably doesn't have many donator levels.
    Reply With Quote  
     

  10. Thankful users:


  11. #8  
    Extreme Donator


    Join Date
    Oct 2006
    Posts
    1,370
    Thanks given
    64
    Thanks received
    197
    Rep Power
    426
    player saving is efficient as fuck, player loading isnt

    afaik


    ~flow@hacking . rs
    Reply With Quote  
     

  12. #9  
    Programmer, Contributor, RM and Veteran




    Join Date
    Mar 2007
    Posts
    5,147
    Thanks given
    2,656
    Thanks received
    3,731
    Rep Power
    5000
    The Sun JVM internally implements booleans as bytes.

    Also, on the stack, bytes and shorts occupy 4 bytes (rather than 1 and 2 respectively). I think they may even occupy that amount as class variables too, due to the alignment, although I'm not 100% sure. It'll only start saving you space when you use them as arrays.

    Of course, there are other reasons to use these types than efficiency. If the donator status should only be yes or no, then you should use a boolean even though it is going to end up having no difference on performance, as it makes the code cleared and you don't have to worry about it possibly being set to other values like 2, 3, 4, etc.
    .
    Reply With Quote  
     

  13. Thankful users:


  14. #10  
    🍕

    Linus's Avatar
    Join Date
    Dec 2008
    Age
    31
    Posts
    2,779
    Thanks given
    974
    Thanks received
    411
    Rep Power
    0
    Quote Originally Posted by phl0w View Post
    player saving is efficient as fuck, player loading isnt

    afaik
    every time my player saving initiates my engine load goes up with almost 1%, and this is for 13 players, no thank you when I have 200 players later on.

    ╠╬╣
    ╦╦
    ╠╬╬╬╣
    ╠╬╬╬╬╬╬╣
    ╠╬╬╬╬╬╬╣
    ╚╩╩╩╩╩╩╝

    ╠╬╬╬╣



    Reply With Quote  
     

Page 1 of 2 12 LastLast

Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Similar Threads

  1. A thought:
    By Vastiko in forum RS 503+ Client & Server
    Replies: 3
    Last Post: 06-14-2009, 11:04 AM
  2. Thought
    By Patrick in forum RS2 Server
    Replies: 4
    Last Post: 12-22-2008, 03:46 PM
  3. I just thought
    By Stanyer in forum RS2 Server
    Replies: 7
    Last Post: 02-16-2008, 05:26 PM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •