int _tmain(int argc, _TCHAR* argv[]) { // Read(), Write() _ASSERTE(create_very_big_file(L"big.txt", 5120)); // 5120mb == 5GB StopWatch sw; sw.Start(); _ASSERTE(file_copy_using_read_write(L"big.txt", L"big2.txt")); sw.Stop(); print("[info] Read_Write : time elapsed = %f\n", sw.GetDurationSecond()); // Memory Mapeed IO StopWatch sw2; sw2.Start(); _ASSERTE(USER_file_copy_using_memory_map(L"big.txt", L"big3.txt")); sw2.Stop(); print("[info] Memory Mapped : time elapsed = %f\n", sw2.GetDurationSecond()); DeleteFileW(L"big.txt"); DeleteFileW(L"big2.txt"); DeleteFileW(L"big3.txt"); return 0; }
int _tmain(int argc, _TCHAR* argv[]) { uint32_t goalsize = 6144; // 6GB _ASSERTE(create_very_big_file(L"big.txt",goalsize));//목표크기 6GB만큼 파일 생성 StopWatch sw; sw.Start(); _ASSERTE(file_copy_using_read_write(L"big.txt", L"big2.txt")); sw.Stop(); print("info] (Read Write) time elapsed = %f", sw.GetDurationSecond()); LARGE_INTEGER _Filesize; _Filesize.QuadPart = (LONGLONG)(1024*1024)*(LONGLONG)goalsize;//파일의 크기 6GB 설정하기위해 LARGE_INTEGER DWORD bufS = 4096; // read.write에서 buf가 4096이므로 4096설정 PUCHAR buf = (PUCHAR)malloc(bufS); LARGE_INTEGER _Offset; _Offset.QuadPart = 0; //파일을 옮겨주는 계산을 하는데 사용한다. StopWatch sw2; sw2.Start(); FileIoHelper FileHelp; FileHelp.FIOpenForRead(L"big.txt"); FileHelp.FIOCreateFile(L"big3.txt", _Filesize); while(_Filesize.QuadPart > _Offset.QuadPart) { if((_Filesize.QuadPart - _Offset.QuadPart) > (LONGLONG)bufS) bufS = 4096; else bufS = (DWORD)(_Filesize.QuadPart - _Offset.QuadPart); FileHelp.FIOReadFromFile(_Offset, bufS, buf); FileHelp.FIOWriteToFile(_Offset, bufS, buf); _Offset.QuadPart += (LONGLONG)bufS; } sw2.Stop(); print("info] (Memory Map) time elapsed = %f", sw2.GetDurationSecond()); return 0; }
int main(){ StopWatch sw = StopWatch(); create_very_big_file(L"make.bin", 4096); //create_very_big_file 함수 내부에서 LARGE_INTEGER 다룰때 LL 추가 sw.Start(); LARGE_INTEGER file_size_read = { 0 }; LARGE_INTEGER file_offset = { 0 }; unsigned char buf[BUF_SIZE]; FileIoHelper Fi_read= FileIoHelper(); FileIoHelper Fi_write = FileIoHelper(); Fi_read.FIOpenForRead(L"make.bin"); file_size_read.QuadPart = (1024 * 1024) * 4096LL; Fi_write.FIOCreateFile(L"copy.bin", file_size_read); while (DT_SUCCEEDED(Fi_read.FIOReadFromFile(file_offset, BUF_SIZE, buf))){ Fi_write.FIOWriteToFile(file_offset, BUF_SIZE, buf); file_offset.QuadPart += BUF_SIZE; //printf("%d", file_offset.QuadPart); } Fi_read.FIOClose(); Fi_write.FIOClose(); sw.Stop(); printf("using memory map via FileIoHelperClass %f , bufsize = %d \n\n", sw.GetDurationSecond(),BUF_SIZE); sw.Start(); file_copy_using_read_write(L"make.bin", L"copy.bin2"); sw.Stop(); printf("using read write %f\n", sw.GetDurationSecond()); system("pause"); return 0; }
int _tmain(int argc, _TCHAR* argv[]) { _ASSERTE(create_very_big_file(L"big.txt", 1)); StopWatch sw2; sw2.Start(); _ASSERTE(file_copy_using_memory_map(L"big.txt", L"big3.txt")); sw2.Stop(); print("info] time elapsed = %f", sw2.GetDurationSecond()); StopWatch sw; sw.Start(); _ASSERTE(file_copy_using_read_write(L"big.txt", L"big2.txt")); sw.Stop(); print("info] time elapsed = %f", sw.GetDurationSecond()); return 0; }
int _tmain(int argc, _TCHAR* argv[]) { /* _ASSERTE(create_very_big_file(L"big.txt", 5000)); StopWatch sw2; sw2.Start(); _ASSERTE(file_copy_using_memory_map(L"big.txt", L"big3.txt")); sw2.Stop(); print("info] time elapsed = %f", sw2.GetDurationSecond()); StopWatch sw; sw.Start(); _ASSERTE(file_copy_using_read_write(L"big.txt", L"big4.txt")); sw.Stop(); print("info] time elapsed = %f", sw.GetDurationSecond()); */ FileIoHelper Helper; uint64_t size=5000; LARGE_INTEGER file_size; LARGE_INTEGER offset; offset.QuadPart = 0; DWORD bufsize = 2048*1024*1024; PUCHAR buf = (PUCHAR)malloc(bufsize); file_size.QuadPart = (1024 * 1024) * size; _ASSERTE(create_very_big_file(L"big.txt", size)); StopWatch sw2; sw2.Start(); Helper.FIOpenForRead(L"big.txt"); Helper.FIOCreateFile(L"big2.txt", file_size); while (offset.QuadPart < file_size.QuadPart) { if ((file_size.QuadPart - offset.QuadPart) >(LONGLONG)bufsize) { bufsize = 2048*1024*1024; } else { bufsize = (DWORD)(file_size.QuadPart - offset.QuadPart); } Helper.FIOReadFromFile(offset, bufsize, buf); Helper.FIOWriteToFile(offset, bufsize, buf); offset.QuadPart += (LONGLONG)bufsize; } sw2.Stop(); print("info] time elapsed = %f", sw2.GetDurationSecond()); StopWatch sw; sw.Start(); _ASSERTE(file_copy_using_read_write(L"big.txt", L"big3.txt")); sw.Stop(); print("info] time elapsed = %f", sw.GetDurationSecond()); _getwch(); return 0; }