Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Лабораторная работа №25.doc
Скачиваний:
16
Добавлен:
01.05.2014
Размер:
167.94 Кб
Скачать

Оптимизированная программа

Turbo Profiler Version 2.1 Sun Apr 17 12:21:41 2005

Program: D:\ETU\8‘…Њ…‘~1\Њ…’ђЋ‹~1\LAB2\3_PART~1\PLAB1.EXE File PLAB1.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.0556 900 begin

0.0009 900 fx:=exp(-x*x)

0.0008 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.0000 100 begin

0.0000 100 pieces:=2;

0.0000 100 delta_x:=(upper-lower)/pieces;

0.0002 100 odd_sum:=fx(lower+delta_x);

0.0000 100 even_sum:=0.0;

0.0003 100 end_sum:=fx(lower)+fx(upper);

0.0000 100 sum:=(end_sum+4.0*odd_sum)*delta_x/3.0;

repeat

0.0001 200 pieces:=pieces*2;

0.0001 200 sum1:=sum;

0.0001 200 delta_x:=(upper-lower)/pieces;

0.0001 200 even_sum:=even_sum+odd_sum;

0.0001 200 odd_sum:=0.0;

0.0001 200 for i:=1 to pieces div 2 do

begin

0.0005 600 x:=lower+delta_x*(2.0*i-1.0);

0.0011 600 odd_sum:=odd_sum+fx(x)

0.0005 600 end;

0.0013 200 sum:=(end_sum+4.0*odd_sum+2.0*even_sum)*delta_x/3.0;

0.0001 200 until abs(sum-sum1)<=abs(tol*sum1)

0.0550 100 end;

0.0011 1 begin

0.0000 1 for j:=1 to 100 do

begin

0.0000 100 twopi:=2.0/sqrt(pi);

0.0000 100 lower:=0.0;

0.0000 100 upper := 1;

0.0000 100 if upper >= 0.0 then

begin

0.0000 100 simps(lower,upper,tol,sum);

0.0000 100 erf:=twopi*sum;

end

0.0549 100 end

0.0010 1 end.

Профилирование по времени

Turbo Profiler Version 2.1 Sun Apr 17 12:22:22 2005

Program: D:\ETU\8‘…Њ…‘~1\Њ…’ђЋ‹~1\LAB2\3_PART~1\PLAB1.EXE

Execution Profile

Total time: 0.1760 sec

% of total: 100%

Run: 1 of 1

Filter: All

Show: Time

Sort: Frequency

PLAB1.FX 0.0556 sec 31% |**********************************************

PLAB1.38 0.0550 sec 31% |*********************************************

PLAB1.52 0.0549 sec 31% |*********************************************

PLAB1.36 0.0013 sec <1% |*

PLAB1.40 0.0011 sec <1% |

PLAB1.34 0.0011 sec <1% |

PLAB1.54 0.0010 sec <1% |

PLAB1.9 0.0009 sec <1% |

PLAB1.10 0.0008 sec <1% |

PLAB1.33 0.0005 sec <1% |

PLAB1.35 0.0005 sec <1% |

PLAB1.23 0.0003 sec <1% |

PLAB1.21 0.0002 sec <1% |

PLAB1.29 0.0001 sec <1% |

PLAB1.28 0.0001 sec <1% |

PLAB1.31 0.0001 sec <1% |

PLAB1.30 0.0001 sec <1% |

PLAB1.37 0.0001 sec <1% |

PLAB1.26 0.0001 sec <1% |

PLAB1.27 0.0001 sec <1% |

PLAB1.45 0.0000 sec <1% |

PLAB1.20 0.0000 sec <1% |

PLAB1.22 0.0000 sec <1% |

PLAB1.19 0.0000 sec <1% |

PLAB1.44 0.0000 sec <1% |

PLAB1.SIMPS 0.0000 sec <1% |

PLAB1.46 0.0000 sec <1% |

PLAB1.47 0.0000 sec <1% |

PLAB1.49 0.0000 sec <1% |

PLAB1.24 0.0000 sec <1% |

PLAB1.50 0.0000 sec <1% |

PLAB1.42 0.0000 sec <1% |

Профилирование по частоте

Turbo Profiler Version 2.1 Sun Apr 17 12:22:52 2005

Program: D:\ETU\8‘…Њ…‘~1\Њ…’ђЋ‹~1\LAB2\3_PART~1\PLAB1.EXE

Execution Profile

Total time: 0.1760 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.33 600 7% |++++++++++++++++++++++++++++++

PLAB1.34 600 7% |++++++++++++++++++++++++++++++

PLAB1.35 600 7% |++++++++++++++++++++++++++++++

PLAB1.30 200 2% |++++++++++

PLAB1.36 200 2% |++++++++++

PLAB1.37 200 2% |++++++++++

PLAB1.31 200 2% |++++++++++

PLAB1.26 200 2% |++++++++++

PLAB1.28 200 2% |++++++++++

PLAB1.27 200 2% |++++++++++

PLAB1.29 200 2% |++++++++++

PLAB1.50 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.38 100 1% |+++++

PLAB1.52 100 1% |+++++

PLAB1.19 100 1% |+++++

PLAB1.44 100 1% |+++++

PLAB1.45 100 1% |+++++

PLAB1.47 100 1% |+++++

PLAB1.46 100 1% |+++++

PLAB1.49 100 1% |+++++

PLAB1.40 1 <1% |

PLAB1.42 1 <1% |

PLAB1.54 1 <1% |

Профилирование по средним временам на 1 вызов

Turbo Profiler Version 2.1 Sun Apr 17 12:23:54 2005

Program: D:\ETU\8‘…Њ…‘~1\Њ…’ђЋ‹~1\LAB2\3_PART~1\PLAB1.EXE

Execution Profile

Total time: 0.1760 sec

% of total: 100%

Run: 1 of 1

Filter: All

Show: Time per call

Sort: Frequency

PLAB1.40 0.0011 sec/call |**********************************************

PLAB1.54 0.0010 sec/call |*****************************************

PLAB1.38 0.0005 sec/call |*********************

PLAB1.52 0.0005 sec/call |*********************

PLAB1.FX 0.0000 sec/call |**

PLAB1.36 0.0000 sec/call |

PLAB1.23 0.0000 sec/call |

PLAB1.21 0.0000 sec/call |

PLAB1.34 0.0000 sec/call |

PLAB1.20 0.0000 sec/call |

PLAB1.26 0.0000 sec/call |

PLAB1.27 0.0000 sec/call |

PLAB1.28 0.0000 sec/call |

PLAB1.29 0.0000 sec/call |

PLAB1.30 0.0000 sec/call |

PLAB1.31 0.0000 sec/call |

PLAB1.19 0.0000 sec/call |

PLAB1.24 0.0000 sec/call |

PLAB1.35 0.0000 sec/call |

PLAB1.22 0.0000 sec/call |

PLAB1.37 0.0000 sec/call |

PLAB1.SIMPS 0.0000 sec/call |

PLAB1.10 0.0000 sec/call |

PLAB1.42 0.0000 sec/call |

PLAB1.44 0.0000 sec/call |

PLAB1.45 0.0000 sec/call |

PLAB1.46 0.0000 sec/call |

PLAB1.47 0.0000 sec/call |

PLAB1.49 0.0000 sec/call |

PLAB1.9 0.0000 sec/call |

PLAB1.50 0.0000 sec/call |

PLAB1.33 0.0000 sec/call |

Вывод: Время работы программы уменьшилось с 0.2172 секунды до 0.1760 секунды (выигрыш по времени составил примерно 19 %), не считая удаления ввода с клавиатуры.