skiplist_test.cpp 966 B

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