Browse Source

写了一些关于测试相关的函数

Gogs 4 months ago
parent
commit
017079cd05
2 changed files with 33 additions and 0 deletions
  1. BIN
      tests/skiplist_test
  2. 33 0
      tests/skiplist_test.cpp

BIN
tests/skiplist_test


+ 33 - 0
tests/skiplist_test.cpp

@@ -0,0 +1,33 @@
+#define _NANXING_TEST_
+#include"../STL/extend/skiplist.h"
+#include"time.h"
+
+void test_insert(int roll,int key_type,int level,bool control)                                //roll代表插入次数,key_type代表给出的key的随机数总数,control代表是否启用init
+{
+    nanxing_extend::skipList<int,int> test{level};
+    int random[key_type];
+    if(control==1)
+    {
+        test.init_skip();               //启用内部随机数表
+    }
+    std::mt19937 rnd(std::chrono::system_clock::now().time_since_epoch().count());
+    for(auto& i:random)
+    {
+        i=static_cast<unsigned int>(rnd());
+    }
+    std::chrono::high_resolution_clock::time_point tp1 = std::chrono::high_resolution_clock::now();
+    
+    for(int i=0;i<roll;i++)
+    {
+        auto get=test.insert(random[i%key_type],i);
+    }
+    test.insert_check();
+
+}
+
+
+int main()
+{
+    std::function<void()> fun{std::bind(test_insert,20000000,10240,15,false)};
+    nanxing_test::time_test(fun);
+}