file_generator.cpp 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. //----------------------------------------------------------------------------
  2. /// @file file_generator.cpp
  3. /// @brief This program generte a file with random information, for to be used
  4. /// in the benchmark programs
  5. ///
  6. /// @author Copyright (c) 2016 Francisco José Tapia (fjtapia@gmail.com )\n
  7. /// Distributed under the Boost Software License, Version 1.0.\n
  8. /// ( See accompanying file LICENSE_1_0.txt or copy at
  9. /// http://www.boost.org/LICENSE_1_0.txt )
  10. /// @version 0.1
  11. ///
  12. /// @remarks
  13. //-----------------------------------------------------------------------------
  14. #include <boost/sort/common/file_vector.hpp>
  15. #include <iostream>
  16. #include <stdio.h>
  17. #include <stdlib.h>
  18. #include <time.h>
  19. #include <vector>
  20. using std::cout;
  21. using std::endl;
  22. namespace bsc = boost::sort::common;
  23. void print_banner();
  24. int main(int argc, char *argv[])
  25. { //---------------------------- begin--------------------------------------
  26. std::string name;
  27. size_t number;
  28. if (argc < 3) {
  29. cout << "This program generate a file filled with random numbers\n";
  30. cout << "of 64 bits\n";
  31. cout << "The invocation format is :\n";
  32. cout << " file_generator file_name number_elements\n\n";
  33. return 0;
  34. };
  35. name = argv[1];
  36. number = atoi(argv[2]);
  37. if (number == 0) {
  38. cout << "error, the number can't be zero\n";
  39. return 0;
  40. };
  41. if (bsc::generate_file(name, number) != 0)
  42. std::cout << "Error in the file creation\n";
  43. return 0;
  44. };
  45. void print_banner()
  46. { //---------------------------- begin -------------------------------------
  47. cout << " The format of this program is :\n";
  48. cout << " file_generator number_elements\n\n";
  49. cout << " The elements are 64 bits random numbers\n";
  50. };