Jump to content
Frequently Asked Questions
  • Are you not able to open the client? Try following our getting started guide
  • Still not working? Try downloading and running JarFix
  • Help! My bot doesn't do anything! Enable fresh start in client settings and restart the client
  • How to purchase with PayPal/OSRS/Crypto gold? You can purchase vouchers from other users
  • Performance wise...


    Calculus

    Recommended Posts

    Posted
    I'm always looking for ways to lower CPU usage on my scripts, and focus my coding practices mainly around this. I don't care if writing a method only takes up one line, if it uses 20% of your CPU, it's a bad method.

     

    Keeping that in mind, when you use the sleepUntil() method...it checks the condition you pass it in order. It would therefore make sense to do boolean checks which require the least amount of CPU power first, to make sure they have the chance of failing first before moving on to more CPU intensive activities...

     

    TLDR: Which method requires more CPU power: tile.equals(otherTile) OR string.equals(otherString)

     

    I don't have access to the tile.equals source code so I can't estimate on my own...

    Posted

    assuming dreambot does tile the same as every other bot, String#equals is more cpu intensive 

    Posted

    You have to think about "the amount of" primitive data types it would require to do the same check. For instance a String with 1 character will takes less than one with 20. And comparing booleans ints longs are faster than most objects compares. And in the case of the string or tile the tile uses 3 int compares while the string uses a lot of characters.

    Posted

    Assuming string.equals is comparing each character, string.equals is O(n) (where n is length of string) while tile.equals is O(1).

    Posted

    Assuming string.equals is comparing each character, string.equals is O(n) (where n is length of string) while tile.equals is O(1).

    Isn't it O(3) because x y z?

    Posted

    Isn't it O(3) because x y z?

    Regular object he's talking about, not a Tile object :P

     

    Or one string with the xyz values in it :P

    Posted

    Isn't it O(3) because x y z?

    That's not how it works, it'd be O(1) because it's a constant time function regardless of input.

    Posted

    That's not how it works, it'd be O(1) because it's a constant time function regardless of input.

    Ah yes.

    Archived

    This topic is now archived and is closed to further replies.

    ×
    ×
    • Create New...

    Important Information

    We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.