Subversion Repositories shark

Rev

Rev 1624 | Blame | Compare with Previous | Last modification | View Log | RSS feed

/*
 *
 *
 *
 */


#include <ll/i386/cons.h>
#include <kernel/func.h>

#include <fs/bdevinit.h>
#include <fs/bdev.h>

#include <stdlib.h>
#include <string.h>

#include "common.h"

#define DISKDEVICE "ide/hda1"

#define NUMBLOCK 1000

__dev_t dev;
__uint8_t buffer[2048];

int main(int argc,char *argv[])
{
  __blkcnt_t blk;
  int res;
  int errors;
  TIME sttime,etime;
 
  showmessage("\n"
              "This test read RAMDOMLY data from first hard disk to test\n"
              "disk throughtput.\n"
              "Remeber that the reads are made RANDOMLY block by block so\n"
              "don't worry if you see a VERY low throughtput.\n"
              );
  srand(7);

  dev=bdev_find_byname(DISKDEVICE);
  if (dev<0) {
    cprintf("\nCan't find device to operate with\n");
    return -1;
  }
  cprintf("\nUsing device %s (dev=%04x)\n",DISKDEVICE,dev);

  cprintf("Please wait (reading %i KB ramdomly)...",NUMBLOCK/2);

  sttime=sys_gettime(NULL);  
  errors=0;
  for (blk=0;blk<NUMBLOCK;blk++) {
    res=bdev_read(dev,rand()%5000,buffer);
    if (res!=0) errors++;
  }
  etime=sys_gettime(NULL)-sttime;

  cprintf("\nDone\n\n");
  cprintf("elapse time    : %li sec %li msec\n",
          etime/1000000l,
          (etime/1000l)%1000l);
  cprintf("throughtput    : %6.3f KB/s\n",
          NUMBLOCK*512.0/1024.0/etime*1000000.0);
  //cprintf("soft reset made: %i\n",ide[0].errors);
  cprintf("errors         : %i\n",errors);
  cprintf("\n");
 
  return 0;
}