stress_test.cpp 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. // Copyright (c) 2006-2018 Maxim Khizhinsky
  2. //
  3. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  4. // file LICENSE or copy at http://www.boost.org/LICENSE_1_0.txt)
  5. #include <fstream>
  6. #include <iostream>
  7. #include <cds_test/stress_test.h>
  8. #ifdef CDS_ENABLE_HPSTAT
  9. # include <cds_test/stat_hp_out.h>
  10. # include <cds_test/stat_dhp_out.h>
  11. #endif
  12. namespace cds_test {
  13. static std::string s_stat_prefix( "stat" );
  14. /*static*/ std::string const& property_stream::stat_prefix()
  15. {
  16. return s_stat_prefix;
  17. }
  18. /*static*/ void property_stream::set_stat_prefix( char const* prefix )
  19. {
  20. if ( prefix && prefix[0] )
  21. s_stat_prefix = prefix;
  22. else
  23. s_stat_prefix = "stat";
  24. }
  25. /*static*/ property_stream& stress_fixture::propout()
  26. {
  27. static property_stream s_prop_stream;
  28. return s_prop_stream;
  29. }
  30. /*static*/ void stress_fixture::print_hp_stat()
  31. {
  32. #ifdef CDS_ENABLE_HPSTAT
  33. {
  34. cds::gc::HP::stat st;
  35. cds::gc::HP::statistics( st );
  36. propout() << st;
  37. }
  38. {
  39. cds::gc::DHP::stat st;
  40. cds::gc::DHP::statistics( st );
  41. propout() << st;
  42. }
  43. #endif
  44. }
  45. /*static*/ std::vector<std::string> stress_fixture::load_dictionary()
  46. {
  47. std::vector<std::string> arrString;
  48. std::ifstream s;
  49. char const* filename = "./dictionary.txt";
  50. s.open( filename );
  51. if ( !s.is_open()) {
  52. std::cerr << "WARNING: Cannot open test file " << filename << std::endl;
  53. return arrString;
  54. }
  55. std::string line;
  56. std::getline( s, line );
  57. arrString.reserve( std::stoul( line ));
  58. while ( !s.eof()) {
  59. std::getline( s, line );
  60. if ( !line.empty())
  61. arrString.push_back( std::move( line ));
  62. }
  63. s.close();
  64. return arrString;
  65. }
  66. } // namespace