Last active
October 6, 2022 01:05
-
-
Save theoknock/0df7b407eb1dee6d4b33eaed9f11e2f3 to your computer and use it in GitHub Desktop.
Starts with the clock() time, counts down to zero, and then returns the difference between the end time and the start time. Compare the results between variations of the same code within the recursive function to determine the most efficient implementation.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
clock_t recursive_function(clock_t count) { | |
// Code to measure goes here (lower numbers are better) | |
return (clock_t)(((((clock_t)nil ^ count) && recursive_function(~-count)))); | |
} | |
static void (^speed_test)(void) = ^{ | |
printf("recursive function == %lu\n", -clock() & (recursive_function(clock()) ^ clock())); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment