MSPEED.C 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  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-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
  12. */
  13. /*
  14. * $Source: f:/miner/source/2d/rcs/mspeed.c $
  15. * $Revision: 1.2 $
  16. * $Author: john $
  17. * $Date: 1993/10/15 16:23:32 $
  18. *
  19. * Program for testing video speed.
  20. *
  21. * $Log: mspeed.c $
  22. * Revision 1.2 1993/10/15 16:23:32 john
  23. * y
  24. *
  25. * Revision 1.1 1993/09/08 11:43:59 john
  26. * Initial revision
  27. *
  28. *
  29. */
  30. #include <stdlib.h>
  31. #include <stdio.h>
  32. #include <conio.h>
  33. #include <math.h>
  34. #include "gr.h"
  35. #include "grdef.h"
  36. #include "timer.h"
  37. #define RelTime(x) (((float)(x*100/fastest))/100.0)
  38. unsigned int MyPoly[100];
  39. char TempBufferX[320*200+16];
  40. char TempBuffer2[320*200+16];
  41. char * TempBuffer1;
  42. char * Video1;
  43. char * Video2;
  44. char * Video4;
  45. char * System1;
  46. char * System2;
  47. char * System4;
  48. main()
  49. {
  50. unsigned int t1, t2, fastest;
  51. unsigned int timeb1v, timeb2v, timeb4v, timeb1s, timeb2s, timeb4s;
  52. unsigned int timew1v, timew2v, timew4v, timew1s, timew2s, timew4s;
  53. unsigned int timed1v, timed2v, timed4v, timed1s, timed2s, timed4s;
  54. gr_init( 0 );
  55. timer_init( 0, NULL );
  56. TempBuffer1 = (unsigned char *)(((unsigned int)TempBufferX+0xF) & 0xFFFFFFF0);
  57. System4 = (unsigned char *)(((unsigned int)TempBuffer2+0xF) & 0xFFFFFFF0);
  58. System2 = (unsigned char *)((unsigned int)System4 + 2);
  59. System1 = (unsigned char *)((unsigned int)System4 + 1);
  60. Video4 = (unsigned char *)0xA0000;
  61. Video2 = (unsigned char *)0xA0002;
  62. Video1 = (unsigned char *)0xA0001;
  63. t1 = timer_get_microseconds();
  64. gr_linear_movsb(TempBuffer1, Video1, 320*200);
  65. t2 = timer_get_microseconds();
  66. t1 = timer_get_microseconds();
  67. gr_linear_movsb(TempBuffer1, Video1, 320*200);
  68. t2 = timer_get_microseconds();
  69. fastest = t2-t1;
  70. if ((t2-t1) < fastest) fastest = t2-t1;
  71. timeb1v = t2 - t1;
  72. t1 = timer_get_microseconds();
  73. gr_linear_movsb(TempBuffer1, Video2, 320*200);
  74. t2 = timer_get_microseconds();
  75. t1 = timer_get_microseconds();
  76. gr_linear_movsb(TempBuffer1, Video2, 320*200);
  77. t2 = timer_get_microseconds();
  78. if ((t2-t1) < fastest) fastest = t2-t1;
  79. timeb2v = t2 - t1;
  80. t1 = timer_get_microseconds();
  81. gr_linear_movsb(TempBuffer1, Video4, 320*200);
  82. t2 = timer_get_microseconds();
  83. t1 = timer_get_microseconds();
  84. gr_linear_movsb(TempBuffer1, Video4, 320*200);
  85. t2 = timer_get_microseconds();
  86. if ((t2-t1) < fastest) fastest = t2-t1;
  87. timeb4v = t2 - t1;
  88. t1 = timer_get_microseconds();
  89. gr_linear_movsb(TempBuffer1, System1, 320*200);
  90. t2 = timer_get_microseconds();
  91. t1 = timer_get_microseconds();
  92. gr_linear_movsb(TempBuffer1, System1, 320*200);
  93. t2 = timer_get_microseconds();
  94. if ((t2-t1) < fastest) fastest = t2-t1;
  95. timeb1s = t2 - t1;
  96. t1 = timer_get_microseconds();
  97. gr_linear_movsb(TempBuffer1, System2, 320*200);
  98. t2 = timer_get_microseconds();
  99. t1 = timer_get_microseconds();
  100. gr_linear_movsb(TempBuffer1, System2, 320*200);
  101. t2 = timer_get_microseconds();
  102. if ((t2-t1) < fastest) fastest = t2-t1;
  103. timeb2s = t2 - t1;
  104. t1 = timer_get_microseconds();
  105. gr_linear_movsb(TempBuffer1, System4, 320*200);
  106. t2 = timer_get_microseconds();
  107. t1 = timer_get_microseconds();
  108. gr_linear_movsb(TempBuffer1, System4, 320*200);
  109. t2 = timer_get_microseconds();
  110. if ((t2-t1) < fastest) fastest = t2-t1;
  111. timeb4s = t2 - t1;
  112. t1 = timer_get_microseconds();
  113. gr_linear_movsw(TempBuffer1, Video1, 320*200);
  114. t2 = timer_get_microseconds();
  115. t1 = timer_get_microseconds();
  116. gr_linear_movsw(TempBuffer1, Video1, 320*200);
  117. t2 = timer_get_microseconds();
  118. if ((t2-t1) < fastest) fastest = t2-t1;
  119. timew1v = t2 - t1;
  120. t1 = timer_get_microseconds();
  121. gr_linear_movsw(TempBuffer1, Video2, 320*200);
  122. t2 = timer_get_microseconds();
  123. t1 = timer_get_microseconds();
  124. gr_linear_movsw(TempBuffer1, Video2, 320*200);
  125. t2 = timer_get_microseconds();
  126. if ((t2-t1) < fastest) fastest = t2-t1;
  127. timew2v = t2 - t1;
  128. t1 = timer_get_microseconds();
  129. gr_linear_movsw(TempBuffer1, Video4, 320*200);
  130. t2 = timer_get_microseconds();
  131. t1 = timer_get_microseconds();
  132. gr_linear_movsw(TempBuffer1, Video4, 320*200);
  133. t2 = timer_get_microseconds();
  134. if ((t2-t1) < fastest) fastest = t2-t1;
  135. timew4v = t2 - t1;
  136. t1 = timer_get_microseconds();
  137. gr_linear_movsw(TempBuffer1, System1, 320*200);
  138. t2 = timer_get_microseconds();
  139. t1 = timer_get_microseconds();
  140. gr_linear_movsw(TempBuffer1, System1, 320*200);
  141. t2 = timer_get_microseconds();
  142. if ((t2-t1) < fastest) fastest = t2-t1;
  143. timew1s = t2 - t1;
  144. t1 = timer_get_microseconds();
  145. gr_linear_movsw(TempBuffer1, System2, 320*200);
  146. t2 = timer_get_microseconds();
  147. t1 = timer_get_microseconds();
  148. gr_linear_movsw(TempBuffer1, System2, 320*200);
  149. t2 = timer_get_microseconds();
  150. if ((t2-t1) < fastest) fastest = t2-t1;
  151. timew2s = t2 - t1;
  152. t1 = timer_get_microseconds();
  153. gr_linear_movsw(TempBuffer1, System4, 320*200);
  154. t2 = timer_get_microseconds();
  155. t1 = timer_get_microseconds();
  156. gr_linear_movsw(TempBuffer1, System4, 320*200);
  157. t2 = timer_get_microseconds();
  158. if ((t2-t1) < fastest) fastest = t2-t1;
  159. timew4s = t2 - t1;
  160. t1 = timer_get_microseconds();
  161. gr_linear_movsd(TempBuffer1, Video1, 320*200);
  162. t2 = timer_get_microseconds();
  163. t1 = timer_get_microseconds();
  164. gr_linear_movsd(TempBuffer1, Video1, 320*200);
  165. t2 = timer_get_microseconds();
  166. if ((t2-t1) < fastest) fastest = t2-t1;
  167. timed1v = t2 - t1;
  168. t1 = timer_get_microseconds();
  169. gr_linear_movsd(TempBuffer1, Video2, 320*200);
  170. t2 = timer_get_microseconds();
  171. t1 = timer_get_microseconds();
  172. gr_linear_movsd(TempBuffer1, Video2, 320*200);
  173. t2 = timer_get_microseconds();
  174. if ((t2-t1) < fastest) fastest = t2-t1;
  175. timed2v = t2 - t1;
  176. t1 = timer_get_microseconds();
  177. gr_linear_movsd(TempBuffer1, Video4, 320*200);
  178. t2 = timer_get_microseconds();
  179. t1 = timer_get_microseconds();
  180. gr_linear_movsd(TempBuffer1, Video4, 320*200);
  181. t2 = timer_get_microseconds();
  182. if ((t2-t1) < fastest) fastest = t2-t1;
  183. timed4v = t2 - t1;
  184. t1 = timer_get_microseconds();
  185. gr_linear_movsd(TempBuffer1, System1, 320*200);
  186. t2 = timer_get_microseconds();
  187. t1 = timer_get_microseconds();
  188. gr_linear_movsd(TempBuffer1, System1, 320*200);
  189. t2 = timer_get_microseconds();
  190. if ((t2-t1) < fastest) fastest = t2-t1;
  191. timed1s = t2 - t1;
  192. t1 = timer_get_microseconds();
  193. gr_linear_movsd(TempBuffer1, System2, 320*200);
  194. t2 = timer_get_microseconds();
  195. t1 = timer_get_microseconds();
  196. gr_linear_movsd(TempBuffer1, System2, 320*200);
  197. t2 = timer_get_microseconds();
  198. if ((t2-t1) < fastest) fastest = t2-t1;
  199. timed2s = t2 - t1;
  200. t1 = timer_get_microseconds();
  201. gr_linear_movsd(TempBuffer1, System4, 320*200);
  202. t2 = timer_get_microseconds();
  203. t1 = timer_get_microseconds();
  204. gr_linear_movsd(TempBuffer1, System4, 320*200);
  205. t2 = timer_get_microseconds();
  206. if ((t2-t1) < fastest) fastest = t2-t1;
  207. timed4s = t2 - t1;
  208. timer_close();
  209. gr_close();
  210. printf( "Relative memory move speeds: \n\n" );
  211. printf( " Vid1 Vid2 Vid4 Sys1 Sys2 Sys4\n" );
  212. 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) );
  213. 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) );
  214. 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) );
  215. printf( "\nA 1.00 corresponds to %d microseconds to move 320x200 unsigned chars.\n", fastest );
  216. return;
  217. }