BigDataSet Experientment
来源:互联网 发布:手机做笔记软件 编辑:程序博客网 时间:2024/05/17 02:29
Environment: Ubuntu 14.04 LTS with GUI
Programing Lanuage: C++ 11
System Workload: light (with no other user defined running program)
Task 1:
enerate 500 Million big int number (0 < int < 1 Trillion) and write them one number per line into a empty file.
Code:
---------------------------------------------------------------------------
void generate_bigDataSet()
{
ofstream myfile;
myfile.open ("example.txt");
int r_min = 0;
int r_max = int (pow(10.0, 9.0));
for(int i=0; i<0.5*r_max;i++)
{
myfile << true_random(r_min,r_max) << "\n";
}
myfile.close();
}
---------------------------------------------------------------------------
Time Consumed: 298.322 s
File Size: 4.9 GB
Task 2:
Generate a int number which is not in the big int data set created above
Code:
----------------------------------------------------------------------------------------------
int collision_detection()
{
int i;
int j;
char buffer[300];
int guess;
string str_buffer;
int int_buffer;
int round = 0;
int r_min = 0;
int r_max = int (pow(10.0, 9.0));
ifstream myfile("example.txt");
while(true)
{
round += 1;
cout << "Round " << round << " Processing...\n";
ifstream myfile("example.txt");
if(myfile.is_open())
{
guess = true_random(r_min, r_max); //pick a guess;
for(i=0; i<0.5*r_max;i++)
{
myfile.getline(buffer,300);
str_buffer = {buffer};
int_buffer = stoi(str_buffer);
if(guess == int_buffer)
{
cout << "Inloop Fail" << guess << "\n";
break;
}
if(i == (0.5*r_max-1))
{
cout << guess;
return guess;
}
}
}
else
cout << "Unable to open file";
myfile.close();
}
return 0;
}
--------------------------------------------------------------------------------------------------------------------------------
Time Consumed: 67.536 s
- BigDataSet Experientment
- Mina 2 编码解码协议 及 已经实现通信的完整代码
- Heritrix只爬取html、htm等特定页面
- sql学习笔记(4)---------常用子句
- C指针编程之道 ---第十一次笔记
- leetcode_Excel Sheet Column Number
- BigDataSet Experientment
- 光学镀膜屏的屏幕保护膜的好处
- Java知识点-受检异常与非受检异常
- swt中text限制只输入数字
- Dell E6400 上装Ubuntu无法使用无线网的问题
- leetcode_Excel Sheet Column Title
- mina 2 心跳包
- ubuntu14.04下python2.7推荐系统Crab搭建
- hdu 3999 The order of a Tree