Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

135 Neutral

About martyj2009

  • Rank

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. martyj2009

    New fast way to loop!

    So there's the for loop. Which works great for most of our programming needs. What if there was a way to speed this up by up to HALF.   Well there is, it's called a five loop.   See below the code example. // Change this to decide which loop to use! #define FIVE 0 #if FIVE #define five for #endif #include <time.h> #include <stdio.h> int main(int argc, const char *argv[]) { int loops = 10000000000; int a, b; clock_t start, end; start = clock(); #if FIVE five(int i = 0; i < loops; i++) #else for (int i = 0; i < loops; i++) #endif { int a = i; b = a * 3; } end = clock(); double seconds = double(end - start) / CLOCKS_PER_SEC; printf("Time Diff: %f", seconds); getchar(); } I know some of you may be doubtful, but the proof is in the pudding.   The for loop results:   Now compare that to the Five loop       Forget Moore's law. We can't rely on chip manufactures to keep up with our software needs. Five loop is here to save the day!    
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!