36 lines
1.1 KiB
C++
36 lines
1.1 KiB
C++
|
#include "tapelib/filetape.h"
|
||
|
#include <cstddef>
|
||
|
#include <cstdlib>
|
||
|
#include <ctime>
|
||
|
#include <fstream>
|
||
|
#include <iostream>
|
||
|
#include <string>
|
||
|
|
||
|
/**
|
||
|
* Generate big input data sets for external sort testing.
|
||
|
* Takes 2 positional arguments - first one is the ouput file name,
|
||
|
* secon one is the amount of random cells that will be generated.
|
||
|
* Each cell value is in range [0; RAND_MAX]
|
||
|
*/
|
||
|
int main(int argc, char *argv[]) {
|
||
|
if (argc < 3) {
|
||
|
std::cerr << "Not enough arguments" << std::endl;
|
||
|
return -1;
|
||
|
}
|
||
|
std::string out_name = argv[1]; // NOLINT
|
||
|
size_t cells = std::stoi(argv[2]); // NOLINT
|
||
|
std::ofstream out(out_name);
|
||
|
if (!out.is_open()) {
|
||
|
std::cerr << "Failed to open file" << std::endl;
|
||
|
return -1;
|
||
|
}
|
||
|
srand(time(nullptr));
|
||
|
out << std::setfill('0') << std::setw(tape::FT_CELL_SIZE)
|
||
|
<< std::to_string(rand());
|
||
|
for (size_t i = 1; i < cells; i++) {
|
||
|
out << tape::FT_DELIMETER << std::setfill('0')
|
||
|
<< std::setw(tape::FT_CELL_SIZE) << std::to_string(rand());
|
||
|
}
|
||
|
return 0;
|
||
|
}
|