1 //////////////////////////////////////////////////////////////////
2 QString _GetIntervalTime(QTime& time, QString strInfo)
3 {
4 int ntime_Diff = time.elapsed();//返回从上次start()或restart()开始以来的时间差,单位ms
5 //以下方法是将ms转为s
6 float f = ntime_Diff/1000.0;
7 QString tr_timeDiff = QString("%1").arg(f); //float->QString
8 return strInfo + ": " + tr_timeDiff;
9 }
10
11 void _WriteFile(QString str)
12 {
13 QString strFileName = "E:/debug.txt";
14 QFile::remove(strFileName);
15 QFile myfile(strFileName);
16 myfile.open(QIODevice::WriteOnly);
17 myfile.write(str.toLatin1());
18 myfile.close();
19 }
20 //---------------------------------------------------------------------------------------
21 void A::excuteSimulation()
22 {
23 TfSimulation mTfSim(mRenderView);
24
25 QTime time;//开始计时
26 QString strInfo;
27 time.start();
28
30 strInfo += _GetIntervalTime(time, QString::fromLocal8Bit("simPanel: ")) + ("\r\n");
31 strInfo += _GetIntervalTime(timeTotal, QString::fromLocal8Bit("TotalTime: ")) + ("\r\n");
32 _WriteFile(strInfo);
33 }