πŸš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: ch.comp.os.linux
Article #24139

Re: Millisekunden

#24139
From: 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.
Technical Details
Message-ID: <7as88b$s72$1@vulcan.alphanet.ch>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <Pine.LNX.4.10.9902220956130.7921-100000@alderaan.ethz.ch>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII
X-Google-Thread: f4b73,6ce2d27449c72d8c
X-Google-Attributes: gidf4b73,public
From: Marc SCHAEFER <schaefer@alphanet.ch>
Subject: Re: Millisekunden
Date: 1999/02/22
Message-ID: <7as88b$s72$1@vulcan.alphanet.ch>
X-Deja-AN: 447195019
Content-Transfer-Encoding: 8bit
References: <Pine.LNX.4.10.9902220956130.7921-100000@alderaan.ethz.ch>
Supersedes: <7as7ls$rsa$1@vulcan.alphanet.ch>
Content-Type: text/plain; charset=ISO-8859-1
Organization: ALPHANET NF -- Not for profit telecom research
Mime-Version: 1.0
Reply-To: Marc SCHAEFER <schaefer@alphanet.ch>
Newsgroups: ch.comp.os.linux