예제 #1
0
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;
}
예제 #2
0
bool USER_file_copy_using_memory_map( _In_ const wchar_t* src_file, _In_ const wchar_t* dst_file )
{
	FileIoHelper SRC_FHELP;
	FileIoHelper DST_FHELP;

	LARGE_INTEGER offset = { 0, };
	LARGE_INTEGER * filesize = NULL;
	DWORD size = 1024 * 1024;
	UCHAR* p = NULL;

	PUCHAR Buffer = (PUCHAR)malloc((uint64_t)(1024 * 1024));

	SRC_FHELP.FIOpenForRead(src_file);
	filesize = SRC_FHELP.FileSize();
	SRC_FHELP.FIOClose();

	_ASSERTE(create_very_big_file(dst_file, filesize->QuadPart / (1024 * 1024)));

	SRC_FHELP.FIOpenForRead(src_file);
	DST_FHELP.FIOpenForRead(dst_file);

	while (offset.QuadPart < filesize->QuadPart)
	{
		SRC_FHELP.FIOReadFromFile(offset, size, Buffer);

		DST_FHELP.FIOWriteToFile(offset, size, Buffer);

		offset.QuadPart += size;
	} 

	DST_FHELP.FIOClose();
	SRC_FHELP.FIOClose();

	return true;
}
예제 #3
0
파일: os_hw2.cpp 프로젝트: kahissa/hw2
int _tmain(int argc, _TCHAR* argv[])
{
	uint32_t uSize = 5000; // 4gb 이상 가능
	LARGE_INTEGER Size;    // 

	DWORD bufSize = 2048;  // 32bit가 4gb 인데 실질적으로 2gb 사용 가능
	// 그러니 최대인 2048M 씩 할당
	LARGE_INTEGER offset;  // 크기
	offset.QuadPart = (LONGLONG)0;

	StopWatch sw1, sw2;



	Size.QuadPart = (LONGLONG)(1024 * 1024) * (LONGLONG)uSize;;

	_ASSERTE(create_very_big_file(L"big.txt", uSize));

	sw1.Start();
	_ASSERTE(file_copy_using_read_write(L"big.txt", L"big2.txt"));
	sw1.Stop();
	print("info] time elapsed = %f", sw1.GetDurationSecond());


	PUCHAR buf = (PUCHAR)malloc(bufSize);


	sw2.Start();

	FileIoHelper Helper;
	Helper.FIOpenForRead(L"big.txt");
	Helper.FIOCreateFile(L"big3.txt", Size);

	while (offset.QuadPart < Size.QuadPart)
	{
		if ((Size.QuadPart - offset.QuadPart) >(LONGLONG)bufSize)
			bufSize = 2048;
		else
			bufSize = (DWORD)(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());


	return 0;
}
예제 #4
0
파일: 과제2.cpp 프로젝트: M0nk2y/HW
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;
}
예제 #5
0
파일: HW2.cpp 프로젝트: skyclad0x7b7/HW2
int _tmain(int argc, _TCHAR* argv[])
{
	
	printf("<< Small File Create, Copy! (1GB) >>\n\n");
	LARGE_INTEGER fileSize;
	fileSize.QuadPart = 1024*1024*1024;
	_ASSERTE(create_very_big_file(L"small.txt", 512));

	StopWatch sw1;
	sw1.Start();
	_ASSERTE(file_copy_using_read_write(L"small.txt", L"small1.txt"));
	sw1.Stop();
	print("[*] read & write time elapsed = %f\n", sw1.GetDurationSecond());

	StopWatch sw2;
	sw2.Start();
	_ASSERTE(file_copy_using_memory_map(L"small.txt", L"small2.txt"));
	sw2.Stop();
	print("[*] mmio time elapsed = %f\n", sw2.GetDurationSecond());

	


	printf("\nBig File Create & Copy Start!\n\n");
	_sleep(2);
	
	printf("<< Big File Create, Copy! (10GB) >>\n");
	
	StopWatch sw3;
	sw3.Start();
	_ASSERTE(file_copy_using_read_write(L"big.txt", L"big1.txt"));
	sw3.Stop();
	print("[*] read & write time elapsed = %f\n", sw3.GetDurationSecond());
	/*
	LARGE_INTEGER offset;
	offset.QuadPart=512;
	_ASSERTE(create_very_big_file(L"big.txt", 10*1024));
	FileIoHelper *a = new FileIoHelper;
	LARGE_INTEGER msize;
	msize.QuadPart = 1024*1024*1024*10;
	StopWatch sw4;
	sw4.Start();
	_ASSERTE(file_copy_using_memory_map(L"big.txt", L"big1.txt"));
	a->FIOpenForRead(L"big.txt");
	a->FIOCreateFile(L"big2.txt", msize);
	sw4.Stop();
	*/
	return 0;
}
예제 #6
0
파일: 2.cpp 프로젝트: limeburst/bob-os
int _tmain(int argc, _TCHAR* argv[])
{
	LARGE_INTEGER fileSize;
	fileSize.QuadPart = 10240000000;
	_ASSERTE(create_very_big_file(L"big.txt", 4));
	StopWatch sw1;
	sw1.Start();
	_ASSERTE(file_copy_using_read_write(L"big.txt", L"big1.txt"));
	sw1.Stop();
	print("info] time elapsed = %f", sw1.GetDurationSecond());
	StopWatch sw2;
	sw2.Start();
	_ASSERTE(file_copy_using_memory_map(L"big.txt", L"big2.txt"));
	sw2.Stop();
	print("info] time elapsed = %f", sw2.GetDurationMilliSecond());
	return 0;
}
예제 #7
0
파일: ic.cpp 프로젝트: pookj/homework2
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;
}
예제 #8
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;
}
예제 #9
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;
}