🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: ch.comp.os.linux
3 messages
3 total messages Started by Andreas 'LionKing' Tscharner Mon, 22 Feb 1999 00:00
Millisekunden
#24131
Author: Andreas 'LionKing' Tscharner
Date: Mon, 22 Feb 1999 00:00
20 lines
1174 bytes
Hallo Welt,

Ich habe ein paar Grafikroutinen geschrieben. Nun möchte ich die Zeit
messen, wei lange z.B. ein PutPixel braucht. Meine Frage: Gibt es in C
eine Library oder Routine, die mir Millisekunden oder acuh Taktzyklen
misst? Soweit ich gesehen habe gibt <time.h> nur Sekunden als kleinste
Einheit an.

Gruss
	Andy


     ("`-''-/").___..--''"`-._
      `o_ o  )   `-.  (     ).`-.__.`)
      (_Y_.)'  ._   )  `._ `. ``-..-'
    _..`--'_..-_/  /--'_.' .'
   (il).-''  (li).'  ((!.-'
   
   Andreas Tscharner		andy@vis.ethz.ch
   	http://www.vis.ethz.ch/~andy
Re: Millisekunden
#24139
Author: Marc SCHAEFER
Date: Mon, 22 Feb 1999 00:00
64 lines
2720 bytes
Andreas 'LionKing' Tscharner <andy@alderaan.ethz.ch> wrote:
> Ich habe ein paar Grafikroutinen geschrieben. Nun m�chte ich die Zeit
> messen, wei lange z.B. ein PutPixel braucht. Meine Frage: Gibt es in C
> eine Library oder Routine, die mir Millisekunden oder acuh Taktzyklen
> misst? Soweit ich gesehen habe gibt <time.h> nur Sekunden als kleinste
> Einheit an.

To my knowledge, timeb is UNIX, and contains seconds and milli.
Beware that the precision might not be to the millisecond, but,
e.g. 1/HZ (1/100 in i386/Linux) of a second.

BTW: you may want to prof(x)ile your C software, there are libraries to
     do that automatically.

#include <time.h>
#include <sys/timeb.h>

static void do_benchmark(int fd, int cmd, unsigned long int max_lba) {
   struct timeb started;
   unsigned long int ms_delta;
   unsigned long int old_lba = 0;
   unsigned long int lba = 0;
   int error;

   if ((error = ioctl(fd, BENCHIO_IOCTL_SET_LBA, 0))) {
      perror("BENCHIO_IOCTL_SET_LBA error");
   }  
   else {
      ftime(&started);

      lba += BUFFER_STEPS * (BUFFER_SIZE / BLOCK_SIZE); /* yep */
   
      while (!error && (lba < max_lba)) {
	 struct timeb ended;

	 error = ioctl(fd,
		       cmd
		       | BENCHIO_IOCTL_FLAGS_DIRECT_LOW,
		       BUFFER_STEPS);
	 lba += BUFFER_STEPS * (BUFFER_SIZE / BLOCK_SIZE);

	 ftime(&ended);
	 ms_delta = ((ended.time - started.time) * 1000)
		     + (ended.millitm - started.millitm);
#define MIN_DELAY 20000 /* 20 sec */
	 if ((ms_delta > MIN_DELAY) || ((lba >= max_lba) && ms_delta)) {
	    printf("Upto LBA %ld : %ld bytes/s.\n",
		   lba,
		   (((lba - old_lba) * 512) / ms_delta) * 1000);
	    old_lba = lba;
	    ftime(&started);
	 }

	 if (error) {
	    perror("ioctl");
	 }
      }
   }
}

If you read all this, this is part of a verrrry simple raw (low-level)
read/write benchmark for SCSI devices displaying LBA/speed graph
which is available on sunsite (benchio). Read the documentation before
starting since the software will destroy your first SCSI hard-drive data.
Re: Millisekunden
#24141
Author: Stefan Heimers
Date: Mon, 22 Feb 1999 00:00
25 lines
1444 bytes
Andreas 'LionKing' Tscharner wrote:
> 
> Hallo Welt,
> 
> Ich habe ein paar Grafikroutinen geschrieben. Nun m�chte ich die Zeit
> messen, wei lange z.B. ein PutPixel braucht. Meine Frage: Gibt es in C
> eine Library oder Routine, die mir Millisekunden oder acuh Taktzyklen
> misst? Soweit ich gesehen habe gibt <time.h> nur Sekunden als kleinste
> Einheit an.

Wie es aussieht willst Du feststellen, wieviel Zeit Dein Programm in
bestimmten Funktionen vertroedelt. Dazu musst Du das Programm nicht
aendern, aber mit der -pg Option kompilieren. Dann laesst Du das
Programm einfach laufen. Es erzeugt ein File mit
profiling-Informationen, das Du nacher mit gprof auswerten kannst.

Siehe man gprof

Stefan


-- 
Stefan Heimers, Klingelbergstrasse 69, CH - 4056 Basel
stefan.heimers@kosta.ch
http://www.datanetworks.ch/~sheimers
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads