Программа newton.Cpp
Turbo Profiler Version 2.1 Thu Apr 22 03:45:18 2004
Program: D:\BORLANDC\BIN\PAS_C2.EXE File E:\WORK\8_CEM\METR\LAP_1\PAS_C2.CPP
Time Counts
#include<stdio.h>
#include<math.h>
//newton
0.0000 8 void func(double x, double & fx, double & dfx)
{
0.0000 8 fx = x*x*x-3*x+1;//ўлзЁб«ҐЁҐ § 票п дгЄжЁЁ
0.0000 8 dfx = 3*x*x - 3; //ўлзЁб«ҐЁҐ § зҐЁп Їа®Ё§ў®¤®©
0.0000 8 }
0.0000 1 void newton(double x) /* newton */
{
0.0000 1 const double tol = 1.0E-9;
0.0000 1 int max = 20;
double fx, dfx, dx, x1;
int i;
char error;
0.0000 1 error = 0;
0.0000 1 i = 0;
do
{
0.0000 8 i = i + 1;
0.0000 8 x1 = x;
0.0000 8 func(x,fx,dfx);
0.0000 8 if (dfx == 0.0)
{
0 0 error = 1;
0 0 x = 1.0;
0 0 printf("%cERROR: slope zero",7);
0 0 }
else
{
0.0000 8 dx = fx/dfx;
0.0000 8 x = x1 - dx;
0.0011 8 printf("x=%f, fx=%f, dfx=%f\n",x,fx,dfx);
}
0.0000 8 }while(!(error || (i > max) || (abs(dx) <= abs(tol*x)) ));
0.0000 1 if (i > max)
{
0 0 printf("%cERROR: no convergence in %d loops\n",7,max);
0 0 error = 1;
}
0.0000 1 } /* newton */
0.0000 1 void main()
{
0.0000 1 double x = 43.356;
0.0000 1 newton(x);//Ї а ¬Ґва x - ЇаЁ¬Ґал© Є®аҐм
0.0000 1 }
Результаты профилирования по времени newton.cpp
Turbo Profiler Version 2.1 Thu Apr 22 03:45:37 2004
Program: D:\BORLANDC\BIN\PAS_C2.EXE
Execution Profile
Total time: 0.0047 sec
% of total: 26 %
Run: 1 of 1
Filter: All
Show: Time
Sort: Frequency
#PAS_C2#38 0.0011 sec 90% |**********************************************
#PAS_C2#25 0.0000 sec 1% |
#PAS_C2#27 0.0000 sec 1% |
#PAS_C2#37 0.0000 sec <1% |
#PAS_C2#8 0.0000 sec <1% |
#PAS_C2#36 0.0000 sec <1% |
#PAS_C2#7 0.0000 sec <1% |
#PAS_C2#28 0.0000 sec <1% |
#PAS_C2#26 0.0000 sec <1% |
func 0.0000 sec <1% |
#PAS_C2#9 0.0000 sec <1% |
#PAS_C2#40 0.0000 sec <1% |
#PAS_C2#51 0.0000 sec <1% |
#PAS_C2#15 0.0000 sec <1% |
#PAS_C2#21 0.0000 sec <1% |
#PAS_C2#50 0.0000 sec <1% |
#PAS_C2#22 0.0000 sec <1% |
#PAS_C2#41 0.0000 sec <1% |
#PAS_C2#46 0.0000 sec <1% |
_main 0.0000 sec <1% |
#PAS_C2#16 0.0000 sec <1% |
newton 0.0000 sec <1% |
#PAS_C2#52 0.0000 sec <1% |
Результаты профилирования по частоте newton.cpp
Turbo Profiler Version 2.1 Thu Apr 22 03:45:49 2004
Program: D:\BORLANDC\BIN\PAS_C2.EXE
Execution Profile
Total time: 0.0047 sec
% of total: 26 %
Run: 1 of 1
Filter: All
Show: Counts
Sort: Frequency
func 8 7% |++++++++++++++++++++++++++++++++++++++++++++++
#PAS_C2#7 8 7% |++++++++++++++++++++++++++++++++++++++++++++++
#PAS_C2#8 8 7% |++++++++++++++++++++++++++++++++++++++++++++++
#PAS_C2#9 8 7% |++++++++++++++++++++++++++++++++++++++++++++++
#PAS_C2#28 8 7% |++++++++++++++++++++++++++++++++++++++++++++++
#PAS_C2#40 8 7% |++++++++++++++++++++++++++++++++++++++++++++++
#PAS_C2#38 8 7% |++++++++++++++++++++++++++++++++++++++++++++++
#PAS_C2#37 8 7% |++++++++++++++++++++++++++++++++++++++++++++++
#PAS_C2#36 8 7% |++++++++++++++++++++++++++++++++++++++++++++++
#PAS_C2#26 8 7% |++++++++++++++++++++++++++++++++++++++++++++++
#PAS_C2#25 8 7% |++++++++++++++++++++++++++++++++++++++++++++++
#PAS_C2#27 8 7% |++++++++++++++++++++++++++++++++++++++++++++++
newton 1 <1% |+++++
#PAS_C2#22 1 <1% |+++++
#PAS_C2#21 1 <1% |+++++
#PAS_C2#16 1 <1% |+++++
#PAS_C2#15 1 <1% |+++++
#PAS_C2#41 1 <1% |+++++
#PAS_C2#46 1 <1% |+++++
_main 1 <1% |+++++
#PAS_C2#51 1 <1% |+++++
#PAS_C2#50 1 <1% |+++++
#PAS_C2#52 1 <1% |+++++
Результаты профилирования по средним временам на 1 вызов newton.cpp
Turbo Profiler Version 2.1 Thu Apr 22 03:46:00 2004
Program: D:\BORLANDC\BIN\PAS_C2.EXE
Execution Profile
Total time: 0.0047 sec
% of total: 26 %
Run: 1 of 1
Filter: All
Show: Time per call
Sort: Frequency
#PAS_C2#38 0.0001 sec/call |**********************************************
#PAS_C2#25 0.0000 sec/call |
#PAS_C2#51 0.0000 sec/call |
#PAS_C2#21 0.0000 sec/call |
#PAS_C2#27 0.0000 sec/call |
#PAS_C2#50 0.0000 sec/call |
#PAS_C2#15 0.0000 sec/call |
func 0.0000 sec/call |
#PAS_C2#22 0.0000 sec/call |
#PAS_C2#16 0.0000 sec/call |
#PAS_C2#26 0.0000 sec/call |
newton 0.0000 sec/call |
#PAS_C2#28 0.0000 sec/call |
#PAS_C2#36 0.0000 sec/call |
#PAS_C2#37 0.0000 sec/call |
#PAS_C2#9 0.0000 sec/call |
#PAS_C2#40 0.0000 sec/call |
#PAS_C2#41 0.0000 sec/call |
#PAS_C2#46 0.0000 sec/call |
_main 0.0000 sec/call |
#PAS_C2#7 0.0000 sec/call |
#PAS_C2#8 0.0000 sec/call |
#PAS_C2#52 0.0000 sec/call |