Subversion Repositories shark

Rev

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

Rev Author Line No. Line
1624 giacomo 1
/*
2
 *
3
 *
4
 *
5
 */
6
 
7
#include <ll/i386/cons.h>
8
#include <kernel/func.h>
9
 
10
#include <fs/bdevinit.h>
11
#include <fs/bdev.h>
12
 
13
#include <stdlib.h>
14
#include <string.h>
15
 
16
#include "common.h"
17
 
18
#define DISKDEVICE "ide/hda1"
19
 
20
#define NUMBLOCK 1000
21
 
22
__dev_t dev;
23
__uint8_t buffer[2048];
24
 
25
int main(int argc,char *argv[])
26
{
27
  __blkcnt_t blk;
28
  int res;
29
  int errors;
30
  TIME sttime,etime;
31
 
32
  showmessage("\n"
33
              "This test read RAMDOMLY data from first hard disk to test\n"
34
              "disk throughtput.\n"
35
              "Remeber that the reads are made RANDOMLY block by block so\n"
36
              "don't worry if you see a VERY low throughtput.\n"
37
              );
38
  srand(7);
39
 
40
  dev=bdev_find_byname(DISKDEVICE);
41
  if (dev<0) {
42
    cprintf("\nCan't find device to operate with\n");
43
    return -1;
44
  }
45
  cprintf("\nUsing device %s (dev=%04x)\n",DISKDEVICE,dev);
46
 
47
  cprintf("Please wait (reading %i KB ramdomly)...",NUMBLOCK/2);
48
 
49
  sttime=sys_gettime(NULL);  
50
  errors=0;
51
  for (blk=0;blk<NUMBLOCK;blk++) {
52
    res=bdev_read(dev,rand()%5000,buffer);
53
    if (res!=0) errors++;
54
  }
55
  etime=sys_gettime(NULL)-sttime;
56
 
57
  cprintf("\nDone\n\n");
58
  cprintf("elapse time    : %li sec %li msec\n",
59
          etime/1000000l,
60
          (etime/1000l)%1000l);
61
  cprintf("throughtput    : %6.3f KB/s\n",
62
          NUMBLOCK*512.0/1024.0/etime*1000000.0);
63
  //cprintf("soft reset made: %i\n",ide[0].errors);
64
  cprintf("errors         : %i\n",errors);
65
  cprintf("\n");
66
 
67
  return 0;
68
}