- •Задание
- •Ознакомиться с документацией на TurboProfiler и выполнить для программ prost0.C и prost0_p.Pas следующее задание:
- •Реализация
- •На Паскале
- •Профилирование программы Prost0 test_cyc.Cpp
- •Профилирование программы Prost0 test_sub.Cpp
- •Оптимизированная программа
- •На Паскале
- •Оптимизированная программа
На Паскале
Turbo Profiler Version 2.1 Sat Apr 16 23:12:04 2005
Program: D:\ETU\8‘…Њ…‘~1\Њ…’ђЋ‹~1\LAB2\3_PART~1\PLAB1_LN.EXE File PLAB1_LN.PAS
Time Counts
program Plab1;
const tol = 1.0E-4;
var sum,upper,lower, erf, twopi : real;
j : integer;
function fx(x: real): real;
0.0582 900 begin
0.0009 900 fx:=exp(-x*x)
0.0034 900 end;
procedure simps(lower,upper,tol : real; var sum : real);
var i : integer;
x,delta_x,even_sum,
odd_sum,end_sum,
sum1 : real;
pieces : integer;
0.0001 100 begin
0.0019 100 pieces:=2;
0.0001 100 delta_x:=(upper-lower)/pieces;
0.0003 100 odd_sum:=fx(lower+delta_x);
0.0000 100 even_sum:=0.0;
0.0005 100 end_sum:=fx(lower)+fx(upper);
0.0002 100 sum:=(end_sum+4.0*odd_sum)*delta_x/3.0;
0.0135 100 writeln(pieces:5,sum);
repeat
0.0001 200 pieces:=pieces*2;
0.0013 200 sum1:=sum;
0.0551 200 delta_x:=(upper-lower)/pieces;
0.0006 200 even_sum:=even_sum+odd_sum;
0.0003 200 odd_sum:=0.0;
0.0002 200 for i:=1 to pieces div 2 do
begin
0.0007 600 x:=lower+delta_x*(2.0*i-1.0);
0.0053 600 odd_sum:=odd_sum+fx(x)
0.0017 600 end;
0.0005 200 sum:=(end_sum+4.0*odd_sum+2.0*even_sum)*delta_x/3.0;
0.0003 200 until abs(sum-sum1)<=abs(tol*sum1)
0.0001 100 end;
0.0012 1 begin
0.0000 1 for j:=1 to 100 do
begin
0.0001 100 twopi:=2.0/sqrt(pi);
0.0001 100 lower:=0.0;
{readln(upper); }
0.0002 100 upper := 1;
0.0000 100 if upper >= 0.0 then
begin
0.0001 100 simps(lower,upper,tol,sum);
0.0550 100 erf:=twopi*sum;
0.0125 100 writeln(upper:7:2, erf:12:8)
end
0.0000 100 end
0.0010 1 end.
Профилирование по времени
Turbo Profiler Version 2.1 Sat Apr 16 23:13:12 2005
Program: D:\ETU\8‘…Њ…‘~1\Њ…’ђЋ‹~1\LAB2\3_PART~1\PLAB1_LN.EXE
Execution Profile
Total time: 0.2172 sec
% of total: 100%
Run: 1 of 1
Filter: All
Show: Time
Sort: Frequency
PLAB1.FX 0.0582 sec 26% |**********************************************
PLAB1.29 0.0551 sec 25% |*******************************************
PLAB1.52 0.0550 sec 25% |*******************************************
PLAB1.25 0.0135 sec 6% |**********
PLAB1.53 0.0125 sec 5% |*********
PLAB1.35 0.0053 sec 2% |****
PLAB1.10 0.0034 sec 1% |**
PLAB1.19 0.0019 sec <1% |*
PLAB1.36 0.0017 sec <1% |*
PLAB1.28 0.0013 sec <1% |*
PLAB1.41 0.0012 sec <1% |
PLAB1.57 0.0010 sec <1% |
PLAB1.9 0.0009 sec <1% |
PLAB1.34 0.0007 sec <1% |
PLAB1.30 0.0006 sec <1% |
PLAB1.37 0.0005 sec <1% |
PLAB1.23 0.0005 sec <1% |
PLAB1.31 0.0003 sec <1% |
PLAB1.38 0.0003 sec <1% |
PLAB1.21 0.0003 sec <1% |
PLAB1.32 0.0002 sec <1% |
PLAB1.24 0.0002 sec <1% |
PLAB1.48 0.0002 sec <1% |
PLAB1.27 0.0001 sec <1% |
PLAB1.SIMPS 0.0001 sec <1% |
PLAB1.45 0.0001 sec <1% |
PLAB1.46 0.0001 sec <1% |
PLAB1.20 0.0001 sec <1% |
PLAB1.39 0.0001 sec <1% |
PLAB1.51 0.0001 sec <1% |
PLAB1.22 0.0000 sec <1% |
PLAB1.55 0.0000 sec <1% |
PLAB1.49 0.0000 sec <1% |
PLAB1.43 0.0000 sec <1% |
Профилирование по частоте
Turbo Profiler Version 2.1 Sat Apr 16 23:13:46 2005
Program: D:\ETU\8‘…Њ…‘~1\Њ…’ђЋ‹~1\LAB2\3_PART~1\PLAB1_LN.EXE
Execution Profile
Total time: 0.2172 sec
% of total: 100%
Run: 1 of 1
Filter: All
Show: Counts
Sort: Frequency
PLAB1.FX 900 11% |++++++++++++++++++++++++++++++++++++++++++++++
PLAB1.10 900 11% |++++++++++++++++++++++++++++++++++++++++++++++
PLAB1.9 900 11% |++++++++++++++++++++++++++++++++++++++++++++++
PLAB1.34 600 7% |++++++++++++++++++++++++++++++
PLAB1.35 600 7% |++++++++++++++++++++++++++++++
PLAB1.36 600 7% |++++++++++++++++++++++++++++++
PLAB1.30 200 2% |++++++++++
PLAB1.37 200 2% |++++++++++
PLAB1.38 200 2% |++++++++++
PLAB1.32 200 2% |++++++++++
PLAB1.31 200 2% |++++++++++
PLAB1.28 200 2% |++++++++++
PLAB1.27 200 2% |++++++++++
PLAB1.29 200 2% |++++++++++
PLAB1.53 100 1% |+++++
PLAB1.25 100 1% |+++++
PLAB1.24 100 1% |+++++
PLAB1.SIMPS 100 1% |+++++
PLAB1.23 100 1% |+++++
PLAB1.22 100 1% |+++++
PLAB1.21 100 1% |+++++
PLAB1.20 100 1% |+++++
PLAB1.39 100 1% |+++++
PLAB1.55 100 1% |+++++
PLAB1.19 100 1% |+++++
PLAB1.45 100 1% |+++++
PLAB1.46 100 1% |+++++
PLAB1.48 100 1% |+++++
PLAB1.51 100 1% |+++++
PLAB1.49 100 1% |+++++
PLAB1.52 100 1% |+++++
PLAB1.41 1 <1% |
PLAB1.43 1 <1% |
PLAB1.57 1 <1% |
Профилирование по средним временам на 1 вызов
Turbo Profiler Version 2.1 Sat Apr 16 23:13:46 2005
Program: D:\ETU\8‘…Њ…‘~1\Њ…’ђЋ‹~1\LAB2\3_PART~1\PLAB1_LN.EXE
Execution Profile
Total time: 0.2172 sec
% of total: 100%
Run: 1 of 1
Filter: All
Show: Counts
Sort: Frequency
PLAB1.FX 900 11% |++++++++++++++++++++++++++++++++++++++++++++++
PLAB1.10 900 11% |++++++++++++++++++++++++++++++++++++++++++++++
PLAB1.9 900 11% |++++++++++++++++++++++++++++++++++++++++++++++
PLAB1.34 600 7% |++++++++++++++++++++++++++++++
PLAB1.35 600 7% |++++++++++++++++++++++++++++++
PLAB1.36 600 7% |++++++++++++++++++++++++++++++
PLAB1.30 200 2% |++++++++++
PLAB1.37 200 2% |++++++++++
PLAB1.38 200 2% |++++++++++
PLAB1.32 200 2% |++++++++++
PLAB1.31 200 2% |++++++++++
PLAB1.28 200 2% |++++++++++
PLAB1.27 200 2% |++++++++++
PLAB1.29 200 2% |++++++++++
PLAB1.53 100 1% |+++++
PLAB1.25 100 1% |+++++
PLAB1.24 100 1% |+++++
PLAB1.SIMPS 100 1% |+++++
PLAB1.23 100 1% |+++++
PLAB1.22 100 1% |+++++
PLAB1.21 100 1% |+++++
PLAB1.20 100 1% |+++++
PLAB1.39 100 1% |+++++
PLAB1.55 100 1% |+++++
PLAB1.19 100 1% |+++++
PLAB1.45 100 1% |+++++
PLAB1.46 100 1% |+++++
PLAB1.48 100 1% |+++++
PLAB1.51 100 1% |+++++
PLAB1.49 100 1% |+++++
PLAB1.52 100 1% |+++++
PLAB1.41 1 <1% |
PLAB1.43 1 <1% |
PLAB1.57 1 <1% |
Вывод: Попробуем оптимизировать программу за счет удаления вывода writeln.