opt.rig 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. -- Time estimation
  2. -- This program can be used in order to estimate the
  3. -- time of access to Rigal data structures, as well as
  4. -- understand expensive and not expensive operations.
  5. -- Results in speed.res.
  6. -- Measurements are in cs - 1/100 of seconds.
  7. -- The computer clock gives results with resolution
  8. -- not more than 6 cs. So, normally you shouldn't pay attention
  9. -- to fluctuations less than 10 cs.
  10. -- MEASUREMENTS
  11. -- For 5000 times on LEO (IBM AT 486) computer , in 1/100 of seconds
  12. -- counter list-cr tree-cr list[19] tree.(19)
  13. -- Int/11 1600 600 4500 1000 1000
  14. -- Int/72 350 140 1300 220 220
  15. -- Comp/11 65 48 620 80 250
  16. -- Comp/72 11 10 125 13 35
  17. -- Comp/72/Win 11 15 150 16 35
  18. -- LEGEND:
  19. -- Int - interpreter. Comp - compiled program
  20. -- 11 - non-turbo mode. 11 times faster than IBM XT 88 /4.7 MHz
  21. -- 72 - turbo mode. 72 times faster than ------- " --------
  22. -- Win - MS-Windows version.
  23. #M
  24. -- OPEN S 'speed.res';
  25. OPEN S ' ';
  26. $EOLD:=(.0 0 0 0 0 0 0 0.);
  27. $CORR:=0;
  28. -- All tested operations are performed in loops. These loops
  29. -- are controlled by counter. Since we are not interested in
  30. -- time consumed by counter, we have to substract the time
  31. -- consumed by the counter ($CORR) from all experiments.
  32. $MAX:=20000;
  33. -- Useful values: Maximal 20000.
  34. -- Minimal 26
  35. #time();
  36. $I:=1;
  37. LOOP $I+:=1; IF $I=$MAX->BREAK FI; END;
  38. $CORR:=#time();
  39. S<< ' Correction = ' $CORR ' cs used by the counter ' ;
  40. $I:=1;
  41. LOOP $I+:=1; IF $I=$MAX->BREAK FI; $Z!.:=T; END;
  42. S<< ' Creation of list with ' $MAX ' elements ' #time() cs ;
  43. $I:=0;
  44. LOOP $I+:=1; IF $I=$MAX->BREAK FI; $TR++:=<.
  45. #CHR(#ORD(A)+ $I MOD 25)
  46. :T.>; END;
  47. S<< ' Creation of tree with ' $MAX '(different=' #LEN($TR)
  48. ') elements ' #time() cs ;
  49. -- PRINT $TR;
  50. $J:=1;
  51. LOOP
  52. $I:=1;
  53. LOOP $I+:=1; IF $I=$MAX->BREAK FI; $R:=$Z[$J]; END;
  54. S << ' Access to ' $J '-th element of list ' $MAX
  55. ' times ' #time() cs;
  56. $J:=$J+3;
  57. IF $J>=20->BREAK FI;
  58. END;
  59. $J:=0;
  60. LOOP
  61. $LET:=#CHR(#ORD(A)+ $J MOD 26);
  62. $I:=1;
  63. LOOP
  64. $I+:=1;
  65. IF $I=$MAX->BREAK FI;
  66. $R:=$TR.$LET;
  67. END;
  68. S << ' Access to ' $J '-th element (' $LET ') of tree ' $MAX
  69. ' times ' #time() cs;
  70. $J:=$J+3;
  71. IF $J>=26->BREAK FI;
  72. END;
  73. #CALL_PAS(1 'Press ENTER');
  74. ##
  75. #time
  76. /
  77. $E:=#CALL_PAS(89); -- Current time , 8 integers
  78. -- Last 2 are seconds and centi-seconds
  79. -- S<<$E;
  80. $EOLD:=LAST #M $EOLD;
  81. $sec:=$E[7]-$EOLD[7]; -- seconds elapsed after last #time
  82. IF $sec<0 -> $sec+:=60;FI;
  83. $td:=($E[8]-$EOLD[8])
  84. +100*$sec
  85. -LAST #M $CORR;
  86. LAST #M $EOLD:=$E;
  87. RETURN $td/ ##