bug-binutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Unix "time" returns 43.833s. "gprof" returns 438 seconds.


From: Jason Peck
Subject: Unix "time" returns 43.833s. "gprof" returns 438 seconds.
Date: Fri, 25 Mar 2005 19:06:41 -0500

Unix "time" returns 43.833s. gprof returns 438 seconds. Either I'm going
crazy or gprof is reporting a 10x increase? What could be causing this?

STEPS:
dev2 andrew # gcc -pg pci_performance2.c -o pci_performance2
dev2 andrew # time ./pci_performance2

real    0m43.847s
user    0m43.646s
sys     0m0.005s
dev2 andrew # gprof pci_performance2 gmon.out > pci_performance.profile
dev2 andrew # more pci_performance.profile
Flat profile:

Each sample counts as 0.01 seconds.
  %   cumulative   self              self     total
 time   seconds   seconds    calls   s/call   s/call  name
 87.46    381.78   381.78      256     1.49     1.49  readMB
 12.95    438.32    56.53      256     0.22     0.22  writeMB

PROGRAM: 
#include <stdio.h>
#include <sys/mman.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/time.h>
#include <stdlib.h>

void writeMB(int *mem1) {
  int i, j;

  for (i = 0; i < (1024*1024)/4; i++) {
    mem1[i]=i;
  }
  j = mem1[0]; // one read to force writes to flush
}

void readMB(int *mem1) {
  int i, j;

  for (i = 0; i < (1024*1024)/4; i++) {
    j = mem1[i];
  }
}


int main() {
  int fd;
  int *mem1;
  int i, j;

  if((fd=open("/dev/mem", O_RDWR))==-1) {
    perror("Open Failed");
    exit(-1);
  }

  if((mem1=mmap(0, (1024*1024*64), PROT_READ|PROT_WRITE, MAP_SHARED, fd,
0xdc000000))==MAP_FAILED) {
    perror("mmap failed");
    exit(-1);
  }

  for (i = 0; i < 256; i++) {
    writeMB(mem1);
  }
  for (i = 0; i < 256; i++) {
    readMB(mem1);
  }
}






reply via email to

[Prev in Thread] Current Thread [Next in Thread]