MSPEED.C 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. /*
  2. THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
  3. SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO
  4. END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
  5. ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
  6. IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
  7. SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
  8. FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
  9. CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS
  10. AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
  11. COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
  12. */
  13. #include <stdlib.h>
  14. #include <stdio.h>
  15. #include <conio.h>
  16. #include <math.h>
  17. #include "gr.h"
  18. #include "grdef.h"
  19. #include "timer.h"
  20. #define RelTime(x) (((float)(x*100/fastest))/100.0)
  21. unsigned int MyPoly[100];
  22. char TempBufferX[320*200+16];
  23. char TempBuffer2[320*200+16];
  24. char * TempBuffer1;
  25. char * Video1;
  26. char * Video2;
  27. char * Video4;
  28. char * System1;
  29. char * System2;
  30. char * System4;
  31. main()
  32. {
  33. unsigned int t1, t2, fastest;
  34. unsigned int timeb1v, timeb2v, timeb4v, timeb1s, timeb2s, timeb4s;
  35. unsigned int timew1v, timew2v, timew4v, timew1s, timew2s, timew4s;
  36. unsigned int timed1v, timed2v, timed4v, timed1s, timed2s, timed4s;
  37. gr_init( 0 );
  38. timer_init( 0, NULL );
  39. TempBuffer1 = (unsigned char *)(((unsigned int)TempBufferX+0xF) & 0xFFFFFFF0);
  40. System4 = (unsigned char *)(((unsigned int)TempBuffer2+0xF) & 0xFFFFFFF0);
  41. System2 = (unsigned char *)((unsigned int)System4 + 2);
  42. System1 = (unsigned char *)((unsigned int)System4 + 1);
  43. Video4 = (unsigned char *)0xA0000;
  44. Video2 = (unsigned char *)0xA0002;
  45. Video1 = (unsigned char *)0xA0001;
  46. t1 = timer_get_microseconds();
  47. gr_linear_movsb(TempBuffer1, Video1, 320*200);
  48. t2 = timer_get_microseconds();
  49. t1 = timer_get_microseconds();
  50. gr_linear_movsb(TempBuffer1, Video1, 320*200);
  51. t2 = timer_get_microseconds();
  52. fastest = t2-t1;
  53. if ((t2-t1) < fastest) fastest = t2-t1;
  54. timeb1v = t2 - t1;
  55. t1 = timer_get_microseconds();
  56. gr_linear_movsb(TempBuffer1, Video2, 320*200);
  57. t2 = timer_get_microseconds();
  58. t1 = timer_get_microseconds();
  59. gr_linear_movsb(TempBuffer1, Video2, 320*200);
  60. t2 = timer_get_microseconds();
  61. if ((t2-t1) < fastest) fastest = t2-t1;
  62. timeb2v = t2 - t1;
  63. t1 = timer_get_microseconds();
  64. gr_linear_movsb(TempBuffer1, Video4, 320*200);
  65. t2 = timer_get_microseconds();
  66. t1 = timer_get_microseconds();
  67. gr_linear_movsb(TempBuffer1, Video4, 320*200);
  68. t2 = timer_get_microseconds();
  69. if ((t2-t1) < fastest) fastest = t2-t1;
  70. timeb4v = t2 - t1;
  71. t1 = timer_get_microseconds();
  72. gr_linear_movsb(TempBuffer1, System1, 320*200);
  73. t2 = timer_get_microseconds();
  74. t1 = timer_get_microseconds();
  75. gr_linear_movsb(TempBuffer1, System1, 320*200);
  76. t2 = timer_get_microseconds();
  77. if ((t2-t1) < fastest) fastest = t2-t1;
  78. timeb1s = t2 - t1;
  79. t1 = timer_get_microseconds();
  80. gr_linear_movsb(TempBuffer1, System2, 320*200);
  81. t2 = timer_get_microseconds();
  82. t1 = timer_get_microseconds();
  83. gr_linear_movsb(TempBuffer1, System2, 320*200);
  84. t2 = timer_get_microseconds();
  85. if ((t2-t1) < fastest) fastest = t2-t1;
  86. timeb2s = t2 - t1;
  87. t1 = timer_get_microseconds();
  88. gr_linear_movsb(TempBuffer1, System4, 320*200);
  89. t2 = timer_get_microseconds();
  90. t1 = timer_get_microseconds();
  91. gr_linear_movsb(TempBuffer1, System4, 320*200);
  92. t2 = timer_get_microseconds();
  93. if ((t2-t1) < fastest) fastest = t2-t1;
  94. timeb4s = t2 - t1;
  95. t1 = timer_get_microseconds();
  96. gr_linear_movsw(TempBuffer1, Video1, 320*200);
  97. t2 = timer_get_microseconds();
  98. t1 = timer_get_microseconds();
  99. gr_linear_movsw(TempBuffer1, Video1, 320*200);
  100. t2 = timer_get_microseconds();
  101. if ((t2-t1) < fastest) fastest = t2-t1;
  102. timew1v = t2 - t1;
  103. t1 = timer_get_microseconds();
  104. gr_linear_movsw(TempBuffer1, Video2, 320*200);
  105. t2 = timer_get_microseconds();
  106. t1 = timer_get_microseconds();
  107. gr_linear_movsw(TempBuffer1, Video2, 320*200);
  108. t2 = timer_get_microseconds();
  109. if ((t2-t1) < fastest) fastest = t2-t1;
  110. timew2v = t2 - t1;
  111. t1 = timer_get_microseconds();
  112. gr_linear_movsw(TempBuffer1, Video4, 320*200);
  113. t2 = timer_get_microseconds();
  114. t1 = timer_get_microseconds();
  115. gr_linear_movsw(TempBuffer1, Video4, 320*200);
  116. t2 = timer_get_microseconds();
  117. if ((t2-t1) < fastest) fastest = t2-t1;
  118. timew4v = t2 - t1;
  119. t1 = timer_get_microseconds();
  120. gr_linear_movsw(TempBuffer1, System1, 320*200);
  121. t2 = timer_get_microseconds();
  122. t1 = timer_get_microseconds();
  123. gr_linear_movsw(TempBuffer1, System1, 320*200);
  124. t2 = timer_get_microseconds();
  125. if ((t2-t1) < fastest) fastest = t2-t1;
  126. timew1s = t2 - t1;
  127. t1 = timer_get_microseconds();
  128. gr_linear_movsw(TempBuffer1, System2, 320*200);
  129. t2 = timer_get_microseconds();
  130. t1 = timer_get_microseconds();
  131. gr_linear_movsw(TempBuffer1, System2, 320*200);
  132. t2 = timer_get_microseconds();
  133. if ((t2-t1) < fastest) fastest = t2-t1;
  134. timew2s = t2 - t1;
  135. t1 = timer_get_microseconds();
  136. gr_linear_movsw(TempBuffer1, System4, 320*200);
  137. t2 = timer_get_microseconds();
  138. t1 = timer_get_microseconds();
  139. gr_linear_movsw(TempBuffer1, System4, 320*200);
  140. t2 = timer_get_microseconds();
  141. if ((t2-t1) < fastest) fastest = t2-t1;
  142. timew4s = t2 - t1;
  143. t1 = timer_get_microseconds();
  144. gr_linear_movsd(TempBuffer1, Video1, 320*200);
  145. t2 = timer_get_microseconds();
  146. t1 = timer_get_microseconds();
  147. gr_linear_movsd(TempBuffer1, Video1, 320*200);
  148. t2 = timer_get_microseconds();
  149. if ((t2-t1) < fastest) fastest = t2-t1;
  150. timed1v = t2 - t1;
  151. t1 = timer_get_microseconds();
  152. gr_linear_movsd(TempBuffer1, Video2, 320*200);
  153. t2 = timer_get_microseconds();
  154. t1 = timer_get_microseconds();
  155. gr_linear_movsd(TempBuffer1, Video2, 320*200);
  156. t2 = timer_get_microseconds();
  157. if ((t2-t1) < fastest) fastest = t2-t1;
  158. timed2v = t2 - t1;
  159. t1 = timer_get_microseconds();
  160. gr_linear_movsd(TempBuffer1, Video4, 320*200);
  161. t2 = timer_get_microseconds();
  162. t1 = timer_get_microseconds();
  163. gr_linear_movsd(TempBuffer1, Video4, 320*200);
  164. t2 = timer_get_microseconds();
  165. if ((t2-t1) < fastest) fastest = t2-t1;
  166. timed4v = t2 - t1;
  167. t1 = timer_get_microseconds();
  168. gr_linear_movsd(TempBuffer1, System1, 320*200);
  169. t2 = timer_get_microseconds();
  170. t1 = timer_get_microseconds();
  171. gr_linear_movsd(TempBuffer1, System1, 320*200);
  172. t2 = timer_get_microseconds();
  173. if ((t2-t1) < fastest) fastest = t2-t1;
  174. timed1s = t2 - t1;
  175. t1 = timer_get_microseconds();
  176. gr_linear_movsd(TempBuffer1, System2, 320*200);
  177. t2 = timer_get_microseconds();
  178. t1 = timer_get_microseconds();
  179. gr_linear_movsd(TempBuffer1, System2, 320*200);
  180. t2 = timer_get_microseconds();
  181. if ((t2-t1) < fastest) fastest = t2-t1;
  182. timed2s = t2 - t1;
  183. t1 = timer_get_microseconds();
  184. gr_linear_movsd(TempBuffer1, System4, 320*200);
  185. t2 = timer_get_microseconds();
  186. t1 = timer_get_microseconds();
  187. gr_linear_movsd(TempBuffer1, System4, 320*200);
  188. t2 = timer_get_microseconds();
  189. if ((t2-t1) < fastest) fastest = t2-t1;
  190. timed4s = t2 - t1;
  191. timer_close();
  192. gr_close();
  193. printf( "Relative memory move speeds: \n\n" );
  194. printf( " Vid1 Vid2 Vid4 Sys1 Sys2 Sys4\n" );
  195. printf( "REP MOVSB: %#2.2f %#2.2f %#2.2f %#2.2f %#2.2f %#2.2f\n", RelTime(timeb1v),RelTime(timeb2v),RelTime(timeb4v), RelTime(timeb1s),RelTime(timeb2s),RelTime(timeb4s) );
  196. printf( "REP MOVSW: %#2.2f %#2.2f %#2.2f %#2.2f %#2.2f %#2.2f\n", RelTime(timew1v),RelTime(timew2v),RelTime(timew4v), RelTime(timew1s),RelTime(timew2s),RelTime(timew4s) );
  197. printf( "REP MOVSD: %#2.2f %#2.2f %#2.2f %#2.2f %#2.2f %#2.2f\n", RelTime(timed1v),RelTime(timed2v),RelTime(timed4v), RelTime(timed1s),RelTime(timed2s),RelTime(timed4s) );
  198. printf( "\nA 1.00 corresponds to %d microseconds to move 320x200 unsigned chars.\n", fastest );
  199. return;
  200. }