From 3e06b381e9a077ad96d041ff89b016a6fdf0a160 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Thu, 7 Oct 2004 02:10:01 +0000 Subject: [PATCH] Removed profiling code. --- CHANGELOG | 1 + TODO | 1 - physfs.c | 175 ------------------------------------------------------ 3 files changed, 1 insertion(+), 176 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 6e1c18fe..b929dc0c 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -2,6 +2,7 @@ * CHANGELOG. */ +10062004 - Removed profiling code from physfs.c. 09292004 - Every API that can return a list of strings can now use a callback mechanism if the application wants to do it's own allocation or handling on a per-item basis. The guts of those diff --git a/TODO b/TODO index e71d2d98..5cf78b9b 100644 --- a/TODO +++ b/TODO @@ -38,7 +38,6 @@ Some might be dupes, some might be done already. - General code audit. - Multiple write dirs with mount points? - Deprecate PHYSFS_setSaneConfig and move it to extras? -- (Re)move the profiling code in physfs.c. - Why is physfsrwops.c cut-and-pasted into the ruby bindings? - Replace code from SDL... - MIX grabs all archives that no other archivers claim. diff --git a/physfs.c b/physfs.c index 8eaa12de..7fe60385 100644 --- a/physfs.c +++ b/physfs.c @@ -12,11 +12,6 @@ # include #endif -#if (defined PHYSFS_PROFILING) -#include -#include -#endif - #include #include #include @@ -308,164 +303,6 @@ void __PHYSFS_sort(void *entries, PHYSFS_uint32 max, } /* __PHYSFS_sort */ - -#if (defined PHYSFS_PROFILING) - -#define PHYSFS_TEST_SORT_ITERATIONS 150 -#define PHYSFS_TEST_SORT_ELEMENTS (64 * 1024) - -static int __PHYSFS_test_sort_cmp(void *_a, PHYSFS_uint32 x, PHYSFS_uint32 y) -{ - PHYSFS_sint32 *a = (PHYSFS_sint32 *) _a; - PHYSFS_sint32 one = a[x]; - PHYSFS_sint32 two = a[y]; - - if (one < two) - return(-1); - else if (one > two) - return(1); - - return(0); -} /* __PHYSFS_test_sort_cmp */ - - -static void __PHYSFS_test_sort_swap(void *_a, PHYSFS_uint32 x, PHYSFS_uint32 y) -{ - PHYSFS_sint32 *a = (PHYSFS_sint32 *) _a; - PHYSFS_sint32 tmp; - tmp = a[x]; - a[x] = a[y]; - a[y] = tmp; -} /* __PHYSFS_test_sort_swap */ - - -static int __PHYSFS_test_sort_do(PHYSFS_uint32 *timer, - PHYSFS_sint32 *a, PHYSFS_uint32 max, - int (*cmpfn)(void *, PHYSFS_uint32, PHYSFS_uint32), - void (*swapfn)(void *, PHYSFS_uint32, PHYSFS_uint32)) -{ - PHYSFS_uint32 i; - struct timeval starttime, endtime; - - gettimeofday(&starttime, NULL); - __PHYSFS_sort(a, max, cmpfn, swapfn); - gettimeofday(&endtime, NULL); - - for (i = 1; i < max; i++) - { - if (a[i] < a[i - 1]) - return(0); - } /* for */ - - if (timer != NULL) - { - *timer = ( ((endtime.tv_sec - starttime.tv_sec) * 1000) + - ((endtime.tv_usec - starttime.tv_usec) / 1000) ); - } /* if */ - - return(1); -} /* __PHYSFS_test_sort_time */ - - -static void __PHYSFS_test_sort(void) -{ - PHYSFS_uint32 elasped[PHYSFS_TEST_SORT_ITERATIONS]; - PHYSFS_sint32 iter; - PHYSFS_sint32 a[PHYSFS_TEST_SORT_ELEMENTS]; - PHYSFS_sint32 i, x; - int success; - - printf("Testing __PHYSFS_sort (linear presorted) ... "); - for (iter = 0; iter < PHYSFS_TEST_SORT_ITERATIONS; iter++) - { - /* set up array to sort. */ - for (i = 0; i < PHYSFS_TEST_SORT_ELEMENTS; i++) - a[i] = i; - - /* sort it. */ - success = __PHYSFS_test_sort_do(&elasped[iter], - a, PHYSFS_TEST_SORT_ELEMENTS, - __PHYSFS_test_sort_cmp, - __PHYSFS_test_sort_swap); - if (!success) - break; - } /* for */ - - if (!success) - printf("Failed!\n"); - else - { - for (x = 0, iter = 0; iter < PHYSFS_TEST_SORT_ITERATIONS; iter++) - x += elasped[iter]; - - x /= PHYSFS_TEST_SORT_ITERATIONS; - printf("Average run (%lu) ms.\n", (unsigned long) x); - } /* else */ - - printf("Testing __PHYSFS_sort (linear presorted reverse) ... "); - for (iter = 0; iter < PHYSFS_TEST_SORT_ITERATIONS; iter++) - { - /* set up array to sort. */ - for (i = 0, x = PHYSFS_TEST_SORT_ELEMENTS; - i < PHYSFS_TEST_SORT_ELEMENTS; - i++, x--) - { - a[i] = x; - } /* for */ - - /* sort it. */ - success = __PHYSFS_test_sort_do(&elasped[iter], - a, PHYSFS_TEST_SORT_ELEMENTS, - __PHYSFS_test_sort_cmp, - __PHYSFS_test_sort_swap); - if (!success) - break; - } /* for */ - - if (!success) - printf("Failed!\n"); - else - { - for (x = 0, iter = 0; iter < PHYSFS_TEST_SORT_ITERATIONS; iter++) - x += elasped[iter]; - - x /= PHYSFS_TEST_SORT_ITERATIONS; - printf("Average run (%lu) ms.\n", (unsigned long) x); - } /* else */ - - - printf("Testing __PHYSFS_sort (randomized) ... "); - for (iter = 0; iter < PHYSFS_TEST_SORT_ITERATIONS; iter++) - { - /* set up array to sort. */ - for (i = 0; i < PHYSFS_TEST_SORT_ELEMENTS; i++) - a[i] = (PHYSFS_uint32) rand(); - - /* sort it. */ - success = __PHYSFS_test_sort_do(&elasped[iter], - a, PHYSFS_TEST_SORT_ELEMENTS, - __PHYSFS_test_sort_cmp, - __PHYSFS_test_sort_swap); - if (!success) - break; - } /* for */ - - if (!success) - printf("Failed!\n"); - else - { - for (x = 0, iter = 0; iter < PHYSFS_TEST_SORT_ITERATIONS; iter++) - x += elasped[iter]; - - x /= PHYSFS_TEST_SORT_ITERATIONS; - printf("Average run (%lu) ms.\n", (unsigned long) x); - } /* else */ - - printf("__PHYSFS_test_sort() complete.\n\n"); -} /* __PHYSFS_test_sort */ -#endif - - static ErrMsg *findErrorForCurrentThread(void) { ErrMsg *i; @@ -865,18 +702,6 @@ int PHYSFS_init(const char *argv0) /* This makes sure that the error subsystem is initialized. */ __PHYSFS_setError(PHYSFS_getLastError()); -#if (defined PHYSFS_PROFILING) - srand(time(NULL)); - setbuf(stdout, NULL); - printf("\n"); - printf("********************************************************\n"); - printf("Warning! Profiling is built into this copy of PhysicsFS!\n"); - printf("********************************************************\n"); - printf("\n"); - printf("\n"); - __PHYSFS_test_sort(); -#endif - return(1); } /* PHYSFS_init */