delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2008/06/24/22:48:37

X-Recipient: archive-cygwin AT delorie DOT com
X-Spam-Check-By: sourceware.org
From: "Raja Saleru" <raja DOT saleru AT iap-online DOT com>
To: <cygwin AT cygwin DOT com>
Subject: Does profiler works in cygwin ?
Date: Wed, 25 Jun 2008 11:50:20 +0900
Message-ID: <DIEOIJJBNGICGPOHAEGCOEKFCBAA.raja.saleru@iap-online.com>
MIME-Version: 1.0
X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2910.0)
X-Synonym: Copied by Synonym (http://www.modulo.ro/synonym) to: mscopy
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

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/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019