skiplist_test.cpp 1.0 KB

123456789101112131415161718192021222324252627282930313233343536
  1. #define _NANXING_TEST_
  2. #define _RANDOM_LIST_
  3. #define NANXING_DEBUG_
  4. #include"../extend/skiplist.h"
  5. #include"time.h"
  6. void test_insert(int roll,int key_type,int level,bool control) //roll代表插入次数,key_type代表给出的key的随机数总数,control代表是否启用init
  7. {
  8. nanxing_extend::skipList<int,int> test{level};
  9. int random[key_type];
  10. if(control==1)
  11. {
  12. test.create_random_list(); //启用内部随机数表
  13. }
  14. std::mt19937 rnd(std::chrono::system_clock::now().time_since_epoch().count());
  15. for(auto& i:random)
  16. {
  17. i=static_cast<unsigned int>(rnd());
  18. }
  19. std::chrono::high_resolution_clock::time_point tp1 = std::chrono::high_resolution_clock::now();
  20. for(int i=0;i<roll;i++)
  21. {
  22. auto get=test.insert(random[i%key_type],i);
  23. }
  24. test.insert_check();
  25. }
  26. int main()
  27. {
  28. std::function<void()> fun{std::bind(test_insert,2000000,10240,15,false)};
  29. nanxing_test::time_test(fun);
  30. }