Results 1 to 6 of 6
  1. #1
    SP1K3CSGO's Avatar
    Join Date
    Mar 2016
    Gender
    male
    Posts
    284
    Reputation
    10
    Thanks
    922
    My Mood
    Sad

    how to optimize code.

    hey. my hack raises the load of my CPU to 40 percent, and FPS in the game fell from 300 to 130, it's awful. How to optimize my external hack?
    Last edited by SP1K3CSGO; 03-21-2016 at 05:30 AM.

  2. #2
    derkrasseboy's Avatar
    Join Date
    Mar 2015
    Gender
    male
    Location
    right there
    Posts
    117
    Reputation
    10
    Thanks
    7
    Dont calculate values twice like the Player Base or so.. Get it once and Use that variable. If you have any infinite loops add Sleep(1); at the end of the loop to reduce CPU usage.. My Major Tips

  3. The Following User Says Thank You to derkrasseboy For This Useful Post:

    SP1K3CSGO (03-21-2016)

  4. #3
    Background's Avatar
    Join Date
    Jan 2016
    Gender
    male
    Location
    .vimrc
    Posts
    61
    Reputation
    10
    Thanks
    573
    My Mood
    Dead
    - if you are using Threads, try to stop them properly to avoid problems.
    - use a smart allocating memory method and don't use more than you need.
    - think about your algorithms before doing them
    Enjoy

  5. #4
    Yemiez's Avatar
    Join Date
    Jun 2012
    Gender
    male
    Location
    Sweden
    Posts
    2,566
    Reputation
    731
    Thanks
    16,280
    My Mood
    Devilish
    If you dont know how to optimize, stick to one thread untill you learn (Its common sense really).
    Just time your operations, this is how I do it:

    Code:
            // A
            (window->OnTick( ) += []( dx::Window *sender, dx::MessageData &data )
    	{
    		// do yer l33t bhop here
    	}).Every( std::chrono::milliseconds( 55 ) );
    
            // B
    	(window->OnTick( ) += []( dx::Window *sender, dx::MessageData &data )
    	{
    		// do yer l33t trigger here
    	}).Every( std::chrono::milliseconds( 60 ) );
    
            // C
    	(window->OnTick( ) += []( dx::Window *sender, dx::MessageData &data )
    	{
    		// Maybe some random update that only needs to be called every 500 milliseconds
    	}).Every( std::chrono::milliseconds( 500 ) );
    Lambda A would only be called if 55 milliseconds has past since the last call to it.
    Lambda B would only be called if 60 milliseconds has past since the last call to it.
    Lambda C would only be called if 500 milliseconds has past since the last call to it.

    Thats a good way to split each feature into different parts of your code, but still keeping it to 1 thread.

    To implement something like this just create a function wrapper, this is how I do it:
    Event.h
    Last edited by Yemiez; 03-21-2016 at 08:37 AM.

  6. The Following User Says Thank You to Yemiez For This Useful Post:

    SP1K3CSGO (03-21-2016)

  7. #5
    illusionisten's Avatar
    Join Date
    Mar 2016
    Gender
    male
    Posts
    28
    Reputation
    10
    Thanks
    2
    My Mood
    Tired
    Quote Originally Posted by Yamiez View Post
    If you dont know how to optimize, stick to one thread untill you learn (Its common sense really).
    Just time your operations.

    Thats a good way to split each feature into different parts of your code, but still keeping it to 1 thread.
    The danger of using only one thread (which is what this sounds like) is making a hyper-thread, eating away processor power and multi-threading is by far the greater choice.
    Some tips that may help you:

    Check compiler settings
    Erase unused/useless code or store it elsewhere (unless you're using code-optimizing)
    Tend to your thread(s) and their sleeps
    Don't overwrite or make variables over and over unless needed
    Check for memory leaks
    If able, read whole structs in memory instead of calling multiple RPM's
    Update slow old fashioned methods with superior ones
    ++ more

    If you're really interested and not really into ghetto-fixes I'd advice you to read on more pure code related places where people tend to treat their code more gentle.

  8. #6
    Hunter's Avatar
    Join Date
    Dec 2013
    Gender
    male
    Location
    Depths Of My Mind.
    Posts
    17,468
    Reputation
    3771
    Thanks
    6,159
    My Mood
    Cheerful
    1 week has passed and no further replies have been made by the OP. Assuming solved.

    /Closed.

Similar Threads

  1. how to vb6 coding
    By janniekkuenen in forum Debate Fort
    Replies: 4
    Last Post: 05-06-2009, 04:03 AM
  2. How do i code hacks
    By joshzex in forum Programming Tutorials
    Replies: 1
    Last Post: 04-20-2009, 09:51 AM
  3. how do you code?
    By godzilla587 in forum C++/C Programming
    Replies: 1
    Last Post: 03-20-2009, 07:23 PM
  4. how many retail codes 1 account
    By piratek1ll in forum WarRock - International Hacks
    Replies: 8
    Last Post: 05-20-2008, 06:57 PM
  5. how make teleport code
    By june8071 in forum WarRock Korea Hacks
    Replies: 0
    Last Post: 07-29-2007, 07:11 AM