0

I am trying to test the CPU (or execution) running time for a simulation in OMNeT++. Is there any parameter or logfile where I can find the execution time after a simulation?

I have found the "CPU-limit-time" parameter so I guess that what I am looking for must exist too, however I have had no luck so far ;)

I would appreciate your help a lot, and thanks in advance!

4

3 回答 3

1

如果您使用 CMDENV,当模拟完成时,它会打印最后一个事件和经过的时间:

** 事件 #3870352 T=240.2018325552 已用时间:27.090s (0m 27s) 0% 完成速度:ev/sec=142870 simsec/sec=8.86681 ev/simsec=16112.9 消息:创建:1646911 存在:FES 中的 670:0

没有更多事件 - 模拟在事件 #3870352,t=240.2018325552 结束。

在此示例中,它花费了 27.090 秒。如果你愿意,你可以编写一个脚本来提取这个值。

于 2015-03-06T09:04:36.943 回答
1

不,OMNeT++ 不会测量 CPU 时间或用于模拟的挂钟时间(尽管它可以限制 CPU 时间)。您可以使用外部工具进行测量。

只需time在 shell 上使用该命令,它就会开始您的模拟,并在完成时将计时统计信息转储到标准输出中。

$ cd 样品/aloha

$ time ./aloha -u Cmdenv -c PureAloha1 指纹.ini

于 2015-02-12T10:45:43.590 回答
-1

这是由 C++ 提供的:

定义变量来存储 CPU 时间:

double startCPUclocks;
double endCPUclocks;

当一段代码启动时运行以下命令:

    startCPUclocks = clock();
    ... some code here....
    endCPUclocks = clock();

那么cpu时间可以计算为:

   endCPUclocks - startCPUclocks;
于 2015-05-02T00:03:47.873 回答