skyboy

Untitled

Aug 2nd, 2011
85
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package
  2. {
  3. import flash.display.*;
  4. import flash.events.Event;
  5. import flash.utils.*;
  6. import flash.text.*;
  7.  
  8. public class BitwiseLogic extends Sprite
  9. {
  10. private var __logger:TextField = new TextField();
  11. private function row(...cols): void
  12. {
  13. __logger.appendText(cols.join("\t")+"\n");
  14. }
  15.  
  16. public function BitwiseLogic():void {
  17. var logger:TextField = __logger;
  18. logger.autoSize = TextFieldAutoSize.LEFT;
  19. addChild(logger);
  20. stage.addEventListener(MouseEvent.CLICK, start);
  21. }
  22. public function start(e:Event):void {
  23. __logger.text = '';
  24.  
  25. var beforeTime:int;
  26. var afterTime:int;
  27. var logicalTime:int;
  28. const REPS:int = 100000000;
  29. var i:int;
  30. var FALSE:Boolean = false;
  31. var TRUE:Boolean = true;
  32. var NULL:Sprite;
  33. var NOTNULL:Sprite = this;
  34. var bool:Boolean;
  35. var tint:int;
  36.  
  37. row("Test", "&& Time", "& Time");
  38.  
  39. beforeTime = getTimer();
  40. for (i = 0; i < REPS; ++i)
  41. {
  42. bool = FALSE && bool;
  43. }
  44. afterTime = getTimer();
  45. logicalTime = afterTime - beforeTime;
  46.  
  47. beforeTime = getTimer();
  48. for (i = 0; i < REPS; ++i)
  49. {
  50. tint = (int(FALSE) & int(tint));
  51. }
  52. afterTime = getTimer();
  53. row("1-false", logicalTime, (afterTime-beforeTime));
  54.  
  55. beforeTime = getTimer();
  56. for (i = 0; i < REPS; ++i)
  57. {
  58. bool = FALSE && FALSE && FALSE && FALSE && FALSE && bool;
  59. }
  60. afterTime = getTimer();
  61. logicalTime = afterTime - beforeTime;
  62.  
  63. beforeTime = getTimer();
  64. for (i = 0; i < REPS; ++i)
  65. {
  66. tint = (int(FALSE) & int(FALSE) & int(FALSE) & int(FALSE) & int(FALSE) & int(tint));
  67. }
  68. afterTime = getTimer();
  69. row("5-false", logicalTime, (afterTime-beforeTime));
  70.  
  71. beforeTime = getTimer();
  72. for (i = 0; i < REPS; ++i)
  73. {
  74. bool = FALSE && FALSE && FALSE && FALSE && FALSE && FALSE && FALSE && FALSE && FALSE && FALSE && bool;
  75. }
  76. afterTime = getTimer();
  77. logicalTime = afterTime - beforeTime;
  78.  
  79. beforeTime = getTimer();
  80. for (i = 0; i < REPS; ++i)
  81. {
  82. tint = (int(FALSE) & int(FALSE) & int(FALSE) & int(FALSE) & int(FALSE) & int(FALSE) & int(FALSE) & int(FALSE) & int(FALSE) & int(FALSE) & int(tint));
  83. }
  84. afterTime = getTimer();
  85. row("10-false", logicalTime, (afterTime-beforeTime));
  86.  
  87. beforeTime = getTimer();
  88. for (i = 0; i < REPS; ++i)
  89. {
  90. bool = TRUE && bool;
  91. }
  92. afterTime = getTimer();
  93. logicalTime = afterTime - beforeTime;
  94.  
  95. beforeTime = getTimer();
  96. for (i = 0; i < REPS; ++i)
  97. {
  98. tint = (int(TRUE) & int(tint));
  99. }
  100. afterTime = getTimer();
  101. row("1-true", logicalTime, (afterTime-beforeTime));
  102.  
  103. beforeTime = getTimer();
  104. for (i = 0; i < REPS; ++i)
  105. {
  106. bool = TRUE && TRUE && TRUE && TRUE && TRUE && bool;
  107. }
  108. afterTime = getTimer();
  109. logicalTime = afterTime - beforeTime;
  110.  
  111. beforeTime = getTimer();
  112. for (i = 0; i < REPS; ++i)
  113. {
  114. tint = (int(TRUE) & int(TRUE) & int(TRUE) & int(TRUE) & int(TRUE) & int(tint));
  115. }
  116. afterTime = getTimer();
  117. row("5-true", logicalTime, (afterTime-beforeTime));
  118.  
  119. beforeTime = getTimer();
  120. for (i = 0; i < REPS; ++i)
  121. {
  122. bool = TRUE && TRUE && TRUE && TRUE && TRUE && TRUE && TRUE && TRUE && TRUE && TRUE && bool;
  123. }
  124. afterTime = getTimer();
  125. logicalTime = afterTime - beforeTime;
  126.  
  127. beforeTime = getTimer();
  128. for (i = 0; i < REPS; ++i)
  129. {
  130. tint = (int(TRUE) & int(TRUE) & int(TRUE) & int(TRUE) & int(TRUE) & int(TRUE) & int(TRUE) & int(TRUE) & int(TRUE) & int(TRUE) & int(tint));
  131. }
  132. afterTime = getTimer();
  133. row("10-true", logicalTime, (afterTime-beforeTime));
  134.  
  135. beforeTime = getTimer();
  136. for (i = 0; i < REPS; ++i)
  137. {
  138. bool = NULL && bool;
  139. }
  140. afterTime = getTimer();
  141. logicalTime = afterTime - beforeTime;
  142.  
  143. beforeTime = getTimer();
  144. for (i = 0; i < REPS; ++i)
  145. {
  146. tint = (int(NULL != null) & int(tint));
  147. }
  148. afterTime = getTimer();
  149. row("1-null", logicalTime, (afterTime-beforeTime));
  150.  
  151. beforeTime = getTimer();
  152. for (i = 0; i < REPS; ++i)
  153. {
  154. bool = NULL && NULL && NULL && NULL && NULL && bool;
  155. }
  156. afterTime = getTimer();
  157. logicalTime = afterTime - beforeTime;
  158.  
  159. beforeTime = getTimer();
  160. for (i = 0; i < REPS; ++i)
  161. {
  162. tint = (int(NULL!=null) & int(NULL!=null) & int(NULL!=null) & int(NULL!=null) & int(NULL!=null) & int(tint));
  163. }
  164. afterTime = getTimer();
  165. row("5-null", logicalTime, (afterTime-beforeTime));
  166.  
  167. beforeTime = getTimer();
  168. for (i = 0; i < REPS; ++i)
  169. {
  170. bool = NULL && NULL && NULL && NULL && NULL && NULL && NULL && NULL && NULL && NULL && bool;
  171. }
  172. afterTime = getTimer();
  173. logicalTime = afterTime - beforeTime;
  174.  
  175. beforeTime = getTimer();
  176. for (i = 0; i < REPS; ++i)
  177. {
  178. tint = (int(NULL!=null) & int(NULL!=null) & int(NULL!=null) & int(NULL!=null) & int(NULL!=null) & int(NULL!=null) & int(NULL!=null) & int(NULL!=null) & int(NULL!=null) & int(NULL!=null) & int(tint));
  179. }
  180. afterTime = getTimer();
  181. row("10-null", logicalTime, (afterTime-beforeTime));
  182.  
  183. beforeTime = getTimer();
  184. for (i = 0; i < REPS; ++i)
  185. {
  186. bool = NOTNULL && bool;
  187. }
  188. afterTime = getTimer();
  189. logicalTime = afterTime - beforeTime;
  190.  
  191. beforeTime = getTimer();
  192. for (i = 0; i < REPS; ++i)
  193. {
  194. tint = (int(NOTNULL!=null) & int(tint));
  195. }
  196. afterTime = getTimer();
  197. row("1-not null", logicalTime, (afterTime-beforeTime));
  198.  
  199. beforeTime = getTimer();
  200. for (i = 0; i < REPS; ++i)
  201. {
  202. bool = NOTNULL && NOTNULL && NOTNULL && NOTNULL && NOTNULL && bool;
  203. }
  204. afterTime = getTimer();
  205. logicalTime = afterTime - beforeTime;
  206.  
  207. beforeTime = getTimer();
  208. for (i = 0; i < REPS; ++i)
  209. {
  210. tint = (int(NOTNULL!=null) & int(NOTNULL!=null) & int(NOTNULL!=null) & int(NOTNULL!=null) & int(NOTNULL!=null) & int(tint));
  211. }
  212. afterTime = getTimer();
  213. row("5-not null", logicalTime, (afterTime-beforeTime));
  214.  
  215. beforeTime = getTimer();
  216. for (i = 0; i < REPS; ++i)
  217. {
  218. bool = NOTNULL && NOTNULL && NOTNULL && NOTNULL && NOTNULL && NOTNULL && NOTNULL && NOTNULL && NOTNULL && NOTNULL && bool;
  219. }
  220. afterTime = getTimer();
  221. logicalTime = afterTime - beforeTime;
  222.  
  223. beforeTime = getTimer();
  224. for (i = 0; i < REPS; ++i)
  225. {
  226. tint = (int(NOTNULL!=null) & int(NOTNULL!=null) & int(NOTNULL!=null) & int(NOTNULL!=null) & int(NOTNULL!=null) & int(NOTNULL!=null) & int(NOTNULL!=null) & int(NOTNULL!=null) & int(NOTNULL!=null) & int(NOTNULL!=null) & int(tint));
  227. }
  228. afterTime = getTimer();
  229. row("10-not null", logicalTime, (afterTime-beforeTime));
  230. row(bool, tint);
  231. }
  232. }
  233. }
RAW Paste Data