bench_index.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /*
  2. * Tencent is pleased to support the open source community by making wwsearch
  3. * available.
  4. *
  5. * Copyright (C) 2018-present Tencent. All Rights Reserved.
  6. *
  7. * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  8. * use this file except in compliance with the License. You may obtain a copy of
  9. * the License at
  10. *
  11. * https://opensource.org/licenses/Apache-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing, software
  14. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  15. * WARRANTIES OF ANY KIND, either express or implied. See the License for the
  16. * specific language governing permissions and limitations under the License.
  17. */
  18. #pragma once
  19. #include "include/index_wrapper.h"
  20. #include "include/search_util.h"
  21. #include "include/staticstic.h"
  22. #include "random_creater.h"
  23. extern bool g_use_rocksdb;
  24. namespace wwsearch {
  25. typedef struct BenchIndexParams {
  26. uint64_t debug_;
  27. uint64_t run_times_;
  28. uint64_t batch_num_;
  29. uint64_t str_len_;
  30. uint64_t nummeric_attr_num_;
  31. uint64_t string_attr_num_;
  32. uint64_t suffix_attr_num_;
  33. uint64_t max_uin_num_;
  34. uint64_t index_type;
  35. uint64_t perf_rocks;
  36. uint64_t mock;
  37. void Print() {
  38. printf(
  39. "debug:%llu\n"
  40. "run_times_:%llu\n"
  41. "batch_num_:%llu\n"
  42. "str_len_:%llu\n"
  43. "numeric_attr_num:%llu\n"
  44. "string_attr_num:%llu\n"
  45. "suffix_attr_num:%llu\n"
  46. "max_uin_num:%llu\n"
  47. "index_type:%llu\n"
  48. "perf_rocks:%llu\n",
  49. debug_, run_times_, batch_num_, str_len_, nummeric_attr_num_,
  50. string_attr_num_, suffix_attr_num_, max_uin_num_, index_type,
  51. perf_rocks);
  52. }
  53. } BenchIndexParams;
  54. class BenchIndex {
  55. private:
  56. public:
  57. BenchIndex() {}
  58. virtual ~BenchIndex() {}
  59. static const char *Usage;
  60. static const char *Description;
  61. static void Run(wwsearch::ArgsHelper &args);
  62. static void CollectRocksDBPerf(Staticstic *statistic, uint64_t count = 1,
  63. bool quit = false);
  64. static void ThreadRun(DefaultIndexWrapper &wrapper, Staticstic &statistic,
  65. RandomCreater *random_creater,
  66. BenchIndexParams &params);
  67. static void PrintStaitic(Staticstic &statistic);
  68. private:
  69. };
  70. } // namespace wwsearch