|
@@ -0,0 +1,100 @@
|
|
|
+#include <QCoreApplication>
|
|
|
+
|
|
|
+#include <thread>
|
|
|
+#include <chrono>
|
|
|
+#include <iostream>
|
|
|
+
|
|
|
+#include "modulecomm.h"
|
|
|
+
|
|
|
+void * gpa;
|
|
|
+
|
|
|
+std::chrono::time_point<std::chrono::steady_clock, std::chrono::duration<double,std::nano>> t1,t2;
|
|
|
+
|
|
|
+void testcall(const char * strdata,const unsigned int nSize,const unsigned int index,const QDateTime * dt,const char * strmemname)
|
|
|
+{
|
|
|
+ qint64 sendtime;
|
|
|
+ t2 = std::chrono::steady_clock::now();
|
|
|
+ double dr_ns = std::chrono::duration<double,std::nano>(t2-t1).count();
|
|
|
+ memcpy(&sendtime,strdata,8);
|
|
|
+ qDebug("lat is %d ns is %f ",QDateTime::currentMSecsSinceEpoch() - sendtime,dr_ns);
|
|
|
+}
|
|
|
+
|
|
|
+void threadsend()
|
|
|
+{
|
|
|
+ char * strdata = new char[3000000];
|
|
|
+ while(1)
|
|
|
+ {
|
|
|
+ std::this_thread::sleep_for(std::chrono::milliseconds(1000));
|
|
|
+ qint64 ntime = QDateTime::currentMSecsSinceEpoch();
|
|
|
+ memcpy(strdata,&ntime,8);
|
|
|
+
|
|
|
+ iv::modulecomm::ModuleSendMsg(gpa,strdata,2000000);
|
|
|
+ t1 = std::chrono::steady_clock::now();
|
|
|
+ qDebug("send msg.");
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+void testcall2(const char * strdata,const unsigned int nSize,const unsigned int index,const QDateTime * dt,const char * strmemname)
|
|
|
+{
|
|
|
+ qint64 sendtime;
|
|
|
+ t2 = std::chrono::steady_clock::now();
|
|
|
+ double dr_ns = std::chrono::duration<double,std::nano>(t2-t1).count();
|
|
|
+ memcpy(&sendtime,strdata,8);
|
|
|
+ qDebug("lat is %d ns is %f ",QDateTime::currentMSecsSinceEpoch() - sendtime,dr_ns);
|
|
|
+}
|
|
|
+
|
|
|
+void threadsend2()
|
|
|
+{
|
|
|
+ char * strdata = new char[3000000];
|
|
|
+ int nsendlen = 10000;
|
|
|
+ while(1)
|
|
|
+ {
|
|
|
+ std::this_thread::sleep_for(std::chrono::milliseconds(1));
|
|
|
+ qint64 ntime = QDateTime::currentMSecsSinceEpoch();
|
|
|
+ memcpy(strdata,&ntime,8);
|
|
|
+ if(nsendlen<2000000)nsendlen = nsendlen*1001/1000;
|
|
|
+ iv::modulecomm::ModuleSendMsg(gpa,strdata,nsendlen);
|
|
|
+ t1 = std::chrono::steady_clock::now();
|
|
|
+// qDebug("send msg.");
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+#include <future>
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+int main(int argc, char *argv[])
|
|
|
+{
|
|
|
+ QCoreApplication a(argc, argv);
|
|
|
+
|
|
|
+// auto x1 = std::chrono::system_clock::now();
|
|
|
+// std::cout << "秒:"<<std::chrono::duration_cast<std::chrono::seconds>(std::chrono::system_clock::now().time_since_epoch()).count() << std::endl;
|
|
|
+// std::cout << "毫秒:" << std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch()).count()<<std::endl;
|
|
|
+// std::cout << "微秒:" << std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::system_clock::now().time_since_epoch()).count() << std::endl;
|
|
|
+// std::cout << "纳秒:" << std::chrono::duration_cast<std::chrono::nanoseconds>(std::chrono::system_clock::now().time_since_epoch()).count() << std::endl;
|
|
|
+// qint64 naotime = std::chrono::system_clock::now().time_since_epoch().count();
|
|
|
+
|
|
|
+// int j;
|
|
|
+// for(j=0;j<10000000;j++)
|
|
|
+// {
|
|
|
+
|
|
|
+// }
|
|
|
+// auto x2 = std::chrono::system_clock::now();
|
|
|
+// double elapsed =
|
|
|
+// std::chrono::duration_cast<std::chrono::nanoseconds>(std::chrono::system_clock::now() - x1).count();
|
|
|
+
|
|
|
+// qDebug("ela is %f ",elapsed);
|
|
|
+// return 0;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+// gpa = iv::modulecomm::RegisterSend("test1",3000000,1,iv::modulecomm::ModuleComm_INTERIOR);
|
|
|
+// iv::modulecomm::RegisterRecv("test1",testcall,iv::modulecomm::ModuleComm_INTERIOR);
|
|
|
+// std::thread * xthread = new std::thread(threadsend);
|
|
|
+
|
|
|
+ gpa = iv::modulecomm::RegisterSend("test1",1000,1,iv::modulecomm::ModuleComm_INTERIOR);
|
|
|
+ iv::modulecomm::RegisterRecv("test1",testcall2,iv::modulecomm::ModuleComm_INTERIOR);
|
|
|
+// iv::modulecomm::RegisterRecv("test1",testcall2);
|
|
|
+ std::thread * xthread = new std::thread(threadsend2);
|
|
|
+ return a.exec();
|
|
|
+}
|