Hi I would like to know whether we can compile the application in cygwin using -pg and then get the output using gprof.
Consider the below sample application, $ gcc -pg quick.c $ ./a.exe $ gprof -b a.exe gmon.out I am wonder why the time is zero in the below output result? Please help in clarifying this. Thanks and Regards Raja Saleru Output ---------- $ gprof.exe -b a.exe gmon.out Flat profile: Each sample counts as 0.01 seconds. no time accumulated % cumulative self self total time seconds seconds calls Ts/call Ts/call name 0.00 0.00 0.00 1 0.00 0.00 _q_sort 0.00 0.00 0.00 1 0.00 0.00 _quickSort Call graph granularity: each sample hit covers 0 byte(s) no time propagated index % time self children called name 65534 _q_sort [3] 0.00 0.00 1/1 _quickSort [4] [3] 0.0 0.00 0.00 1+65534 _q_sort [3] 65534 _q_sort [3] ----------------------------------------------- 0.00 0.00 1/1 _main [41] [4] 0.0 0.00 0.00 1 _quickSort [4] 0.00 0.00 1/1 _q_sort [3] ----------------------------------------------- ---------------------------------------------------------------------------- -------- /* * Sample Application - quick sort * * This program is used as application to creating gmon.out */ #include <stdlib.h> #include <stdio.h> #define NUM_ITEMS 0xffff void quickSort(int numbers[], int array_size); void q_sort(int numbers[], int left, int right); int numbers[NUM_ITEMS]; int main() { int i; //seed random number generator srand(getpid()); //fill array with random integers for (i = 0; i < NUM_ITEMS; i++) numbers[i] = rand(); //perform quick sort on array quickSort(numbers, NUM_ITEMS); printf("Done with sort.\n"); for (i = 0; i < NUM_ITEMS; i++) printf("%i\n", numbers[i]); } void quickSort(int numbers[], int array_size) { q_sort(numbers, 0, array_size - 1); } void q_sort(int numbers[], int left, int right) { int pivot, l_hold, r_hold; l_hold = left; r_hold = right; pivot = numbers[left]; while (left < right) { while ((numbers[right] >= pivot) && (left < right)) right--; if (left != right) { numbers[left] = numbers[right]; left++; } while ((numbers[left] <= pivot) && (left < right)) left++; if (left != right) { numbers[right] = numbers[left]; right--; } } numbers[left] = pivot; pivot = left; left = l_hold; right = r_hold; if (left < pivot) q_sort(numbers, left, pivot-1); if (right > pivot) q_sort(numbers, pivot+1, right); } ---------------------------------------------------------------------------- -------- -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/