Skip to content

Instantly share code, notes, and snippets.

@theoknock
Last active October 6, 2022 01:05
Show Gist options
  • Save theoknock/0df7b407eb1dee6d4b33eaed9f11e2f3 to your computer and use it in GitHub Desktop.
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.
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