- 积分
- 47
- 注册时间
- 2003-9-12
- 仿真币
-
- 最后登录
- 1970-1-1
|
发表于 2004-5-23 21:57:31
|
显示全部楼层
来自 美国
回复: 【讨论】如何在Fortran程序中计算该程序的运行时间
苍山负雪说得对,用cpu_time具有通用性。如下是关于计时的详细技术文档,其中关于非编程使用批处理文件的方法很有意思:
Methods of Timing Your Application
To perform application timings, use a version of the TIME command in a .BAT file (or the function timing profiling option). You might consider modifying the program to call routines within the program to measure execution time (possibly using conditionally compiled lines). For example:
1. Compaq Fortran intrinsic procedures, such as CPU_TIME, SYSTEM_CLOCK, DATE_AND_TIME, and TIME.
Library routines, such as ETIME or TIME.
2. Visual Fortran programs created in a Windows 98, Windows Me, or Windows 95 development environment can be run and analyzed on Windows NT 4 or Windows 2000 systems. Whenever possible, perform detailed performance analysis on a system that closely resembles the system(s) that will used for actual application use.
Sample Command Procedure that Uses TIME and Performance Monitor
The following example shows a .BAT command procedure that uses the TIME command and the Performance Monitor (perfmon) tool available on Windows NT 4 and Windows 2000 systems. The kill command that stops the perfmon tool is included on the Windows NT Resource kit; if the kill tool is not available on your system, manually end the perfmon task by using the task manager.
This .BAT procedure assumes that the program to be timed is myprog.exe.
Before using this batch file, start the performance monitor to setup logging of the statistics that you are interested in:
1. At the DOS prompt type: Perfmon
2. In the View menu, select Log
3. In the Edit menu, select Add to Log and select some statistics
4. In the Options menu, select Log. In the dialog box:
a. Name the log file. The following .BAT procedure assumes that
you have named the logfile myprog.log.
b. Consider adjusting the Log Interval.
c. As the last step, be sure to select "Start Log".
5. In the File menu, select Save Workspace to save the setup information. The following .BAT procedure assumes you have saved the workspace as my_perfmon_setup.pmw.
The command procedure follows:
-
- echo off
- rem Sample batch file to record performance statistics for later analysis.
- rem This .bat file assumes that you have the utility "kill" available, which
- rem is distributed with the NT resource kit.
-
- rem Delete previous logs, then start up the Performance Monitor.
- rem We use start so that control returns instantly to this batch file.
- del myprog.log
- start perfmon my_perfmon_setup.pmw
-
- rem print the time we started
- time <nul | findstr current
-
- rem start the program we are interested in, this time using
- rem cmd /c so that the batch file waits for the program to finish.
- echo on
- cmd /c myprog.exe
- echo off
-
- rem print the time we stopped
- time <nul | findstr current
-
- rem all done logging statistics
- kill perfmon
- rem if kill is not available, end the perfmon task manually
-
复制代码
After the run, analyze your data by using Performance Monitor:
1. If it is not currently running, start Performance Monitor.
2. In the View menu, select Chart.
3. In the Options menu, select Data From and specify the name of
the logfile.
4. In the Edit menu, select Add To Chart to display the counters. |
评分
-
1
查看全部评分
-
|