Помогаем работать и общаться

Без названия

Публично отправил Гость в 20:43 28-01-2012 с типом cpp и размером 0.74 Kb
Хранить: Вечно, просмотров: 13
В буфер! | Скачать!

  1. #include <time.h>
  2. #include <iostream>
  3. #include <unistd.h>
  4. //#include <stdlib.h>
  5. //#include <stdio.h>
  6. //#include <sys/stat.h>
  7. #include <fcntl.h>
  8. #include <fstream>
  9. #define SIZE 5242880
  10.  
  11. using namespace std;
  12.  
  13. int main()
  14. {
  15.     //time_t T=clock();
  16.    
  17.     char buf[SIZE];
  18.     //char s;
  19.     //ifstream in;
  20.     //in.open("output");
  21.     //in>>s;
  22.     //cout<<"s="<<s;
  23.     int fd = open("output", O_RDONLY);
  24.     cout<<fd<<endl;
  25.     time_t T = clock();
  26.     for(int i=0; i<100; i++)
  27.     {
  28.         ssize_t r = read (fd, buf, SIZE);
  29.     }
  30.     //t = clock()-t;
  31.     close(fd);
  32.    
  33.     for(int i=0; i<10; i++)
  34.         cout<<buf[i]<<' ';
  35.     cout<<endl;
  36.     //cout<<t<<endl;
  37.     cout<<"speed = "<<endl;
  38.     cout<<(clock() - T)<<endl;
  39. }

Комментируй
Исходный текст