Benchfib.deploy.js 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. smalltalk.addClass('Benchfib', smalltalk.Object, [], 'Benchfib');
  2. smalltalk.addMethod(
  3. '_main',
  4. smalltalk.method({
  5. selector: 'main',
  6. fn: function (){
  7. var self=this;
  8. var result=nil;
  9. result=smalltalk.send((0), "_tinyBenchmarks", []);
  10. smalltalk.send((typeof console == 'undefined' ? nil : console), "_log_", [smalltalk.send(unescape("0%20tinyBenchmarks%20%3D%3E%20"), "__comma", [result])]);
  11. return self;}
  12. }),
  13. smalltalk.Benchfib.klass);
  14. smalltalk.addMethod(
  15. '_benchFib',
  16. smalltalk.method({
  17. selector: 'benchFib',
  18. fn: function (){
  19. var self=this;
  20. return (($receiver = self < (2)).klass === smalltalk.Boolean) ? ($receiver ? (function(){return (1);})() : (function(){return (($receiver = (($receiver = smalltalk.send(self - (1), "_benchFib", [])).klass === smalltalk.Number) ? $receiver +smalltalk.send(self - (2), "_benchFib", []) : smalltalk.send($receiver, "__plus", [smalltalk.send(self - (2), "_benchFib", [])])).klass === smalltalk.Number) ? $receiver +(1) : smalltalk.send($receiver, "__plus", [(1)]);})()) : smalltalk.send($receiver, "_ifTrue_ifFalse_", [(function(){return (1);}), (function(){return (($receiver = (($receiver = smalltalk.send(self - (1), "_benchFib", [])).klass === smalltalk.Number) ? $receiver +smalltalk.send(self - (2), "_benchFib", []) : smalltalk.send($receiver, "__plus", [smalltalk.send(self - (2), "_benchFib", [])])).klass === smalltalk.Number) ? $receiver +(1) : smalltalk.send($receiver, "__plus", [(1)]);})]);
  21. return self;}
  22. }),
  23. smalltalk.Number);
  24. smalltalk.addMethod(
  25. '_benchmark',
  26. smalltalk.method({
  27. selector: 'benchmark',
  28. fn: function (){
  29. var self=this;
  30. var size=nil;
  31. var flags=nil;
  32. var prime=nil;
  33. var k=nil;
  34. var count=nil;
  35. size=(8190);
  36. smalltalk.send((1), "_to_do_", [self, (function(iter){count=(0);flags=smalltalk.send((smalltalk.Array || Array), "_new", []);smalltalk.send(size, "_timesRepeat_", [(function(){return smalltalk.send(flags, "_add_", [true]);})]);return smalltalk.send((1), "_to_do_", [size, (function(i){return (($receiver = smalltalk.send(flags, "_at_", [i])).klass === smalltalk.Boolean) ? ($receiver ? (function(){prime=(($receiver = i).klass === smalltalk.Number) ? $receiver +(1) : smalltalk.send($receiver, "__plus", [(1)]);k=(($receiver = i).klass === smalltalk.Number) ? $receiver +prime : smalltalk.send($receiver, "__plus", [prime]);(function(){while((function(){return (($receiver = k).klass === smalltalk.Number) ? $receiver <=size : smalltalk.send($receiver, "__lt_eq", [size]);})()) {(function(){smalltalk.send(flags, "_at_put_", [k, false]);return k=(($receiver = k).klass === smalltalk.Number) ? $receiver +prime : smalltalk.send($receiver, "__plus", [prime]);})()}})();return count=(($receiver = count).klass === smalltalk.Number) ? $receiver +(1) : smalltalk.send($receiver, "__plus", [(1)]);})() : nil) : smalltalk.send($receiver, "_ifTrue_", [(function(){prime=(($receiver = i).klass === smalltalk.Number) ? $receiver +(1) : smalltalk.send($receiver, "__plus", [(1)]);k=(($receiver = i).klass === smalltalk.Number) ? $receiver +prime : smalltalk.send($receiver, "__plus", [prime]);(function(){while((function(){return (($receiver = k).klass === smalltalk.Number) ? $receiver <=size : smalltalk.send($receiver, "__lt_eq", [size]);})()) {(function(){smalltalk.send(flags, "_at_put_", [k, false]);return k=(($receiver = k).klass === smalltalk.Number) ? $receiver +prime : smalltalk.send($receiver, "__plus", [prime]);})()}})();return count=(($receiver = count).klass === smalltalk.Number) ? $receiver +(1) : smalltalk.send($receiver, "__plus", [(1)]);})]);})]);})]);
  37. return count;
  38. return self;}
  39. }),
  40. smalltalk.Number);
  41. smalltalk.addMethod(
  42. '_tinyBenchmarks',
  43. smalltalk.method({
  44. selector: 'tinyBenchmarks',
  45. fn: function (){
  46. var self=this;
  47. var t1=nil;
  48. var t2=nil;
  49. var r=nil;
  50. var n1=nil;
  51. var n2=nil;
  52. n1=(1);
  53. (function(){while((function(){t1=smalltalk.send((smalltalk.Date || Date), "_millisecondsToRun_", [(function(){return smalltalk.send(n1, "_benchmark", []);})]);return (($receiver = t1).klass === smalltalk.Number) ? $receiver <(1000) : smalltalk.send($receiver, "__lt", [(1000)]);})()) {(function(){return n1=(($receiver = n1).klass === smalltalk.Number) ? $receiver *(2) : smalltalk.send($receiver, "__star", [(2)]);})()}})();
  54. n2=(16);
  55. (function(){while((function(){t2=smalltalk.send((smalltalk.Date || Date), "_millisecondsToRun_", [(function(){return r=smalltalk.send(n2, "_benchFib", []);})]);return (($receiver = t2).klass === smalltalk.Number) ? $receiver <(1000) : smalltalk.send($receiver, "__lt", [(1000)]);})()) {(function(){return n2=(($receiver = n2).klass === smalltalk.Number) ? $receiver +(1) : smalltalk.send($receiver, "__plus", [(1)]);})()}})();
  56. return smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send((($receiver = (($receiver = (($receiver = n1).klass === smalltalk.Number) ? $receiver *(500000) : smalltalk.send($receiver, "__star", [(500000)])).klass === smalltalk.Number) ? $receiver *(1000) : smalltalk.send($receiver, "__star", [(1000)])).klass === smalltalk.Number) ? $receiver /t1 : smalltalk.send($receiver, "__slash", [t1]), "_printString", []), "__comma", [unescape("%20bytecodes/sec%3B%20")]), "__comma", [smalltalk.send((($receiver = (($receiver = r).klass === smalltalk.Number) ? $receiver *(1000) : smalltalk.send($receiver, "__star", [(1000)])).klass === smalltalk.Number) ? $receiver /t2 : smalltalk.send($receiver, "__slash", [t2]), "_printString", [])]), "__comma", [unescape("%20sends/sec")]);
  57. return self;}
  58. }),
  59. smalltalk.Number);
  60. smalltalk.addMethod(
  61. '_jsbenchFib',
  62. smalltalk.method({
  63. selector: 'jsbenchFib',
  64. fn: function (){
  65. var self=this;
  66. if (this < 2) {
  67. return 1;
  68. } else {
  69. return (this-1)._jsbenchFib() + (this-2)._jsbenchFib() + 1;};
  70. return self;}
  71. }),
  72. smalltalk.Number);
  73. smalltalk.addMethod(
  74. '_jsbenchmark',
  75. smalltalk.method({
  76. selector: 'jsbenchmark',
  77. fn: function (){
  78. var self=this;
  79. var size = 8190;
  80. var count;
  81. for (var z=0;z<this;z++) {
  82. count = 0;
  83. var flags = new Array();
  84. for (var p=0; p<size; p++) {
  85. flags[p] = true;
  86. }
  87. for (var i=1;i<=size;i++) {
  88. if (flags[i-1]) {
  89. var prime = i+1;
  90. var k = i + prime;
  91. while (k <= size) {
  92. flags[k-1] = false;
  93. k = k + prime;
  94. }
  95. count = count + 1;
  96. }
  97. }
  98. }
  99. return count;
  100. return self;}
  101. }),
  102. smalltalk.Number);
  103. smalltalk.addMethod(
  104. '_jstinyBenchmarks',
  105. smalltalk.method({
  106. selector: 'jstinyBenchmarks',
  107. fn: function (){
  108. var self=this;
  109. var t1=nil;
  110. var t2=nil;
  111. var r=nil;
  112. var n1=nil;
  113. var n2=nil;
  114. n1=(1);
  115. (function(){while((function(){t1=smalltalk.send((smalltalk.Date || Date), "_millisecondsToRun_", [(function(){return smalltalk.send(n1, "_jsbenchmark", []);})]);return (($receiver = t1).klass === smalltalk.Number) ? $receiver <(1000) : smalltalk.send($receiver, "__lt", [(1000)]);})()) {(function(){return n1=(($receiver = n1).klass === smalltalk.Number) ? $receiver *(2) : smalltalk.send($receiver, "__star", [(2)]);})()}})();
  116. n2=(28);
  117. (function(){while((function(){t2=smalltalk.send((smalltalk.Date || Date), "_millisecondsToRun_", [(function(){return r=smalltalk.send(n2, "_jsbenchFib", []);})]);return (($receiver = t2).klass === smalltalk.Number) ? $receiver <(1000) : smalltalk.send($receiver, "__lt", [(1000)]);})()) {(function(){return n2=(($receiver = n2).klass === smalltalk.Number) ? $receiver +(1) : smalltalk.send($receiver, "__plus", [(1)]);})()}})();
  118. return smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send((($receiver = (($receiver = (($receiver = n1).klass === smalltalk.Number) ? $receiver *(500000) : smalltalk.send($receiver, "__star", [(500000)])).klass === smalltalk.Number) ? $receiver *(1000) : smalltalk.send($receiver, "__star", [(1000)])).klass === smalltalk.Number) ? $receiver /t1 : smalltalk.send($receiver, "__slash", [t1]), "_printString", []), "__comma", [unescape("%20bytecodes/sec%3B%20")]), "__comma", [smalltalk.send((($receiver = (($receiver = r).klass === smalltalk.Number) ? $receiver *(1000) : smalltalk.send($receiver, "__star", [(1000)])).klass === smalltalk.Number) ? $receiver /t2 : smalltalk.send($receiver, "__slash", [t2]), "_printString", [])]), "__comma", [unescape("%20sends/sec")]);
  119. return self;}
  120. }),
  121. smalltalk.Number);