skiplist_test.cpp 1001 B

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