json-parse-financial.js 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. /*
  2. Copyright (C) 2007 Apple Inc. All rights reserved.
  3. Redistribution and use in source and binary forms, with or without
  4. modification, are permitted provided that the following conditions
  5. are met:
  6. 1. Redistributions of source code must retain the above copyright
  7. notice, this list of conditions and the following disclaimer.
  8. 2. Redistributions in binary form must reproduce the above copyright
  9. notice, this list of conditions and the following disclaimer in the
  10. documentation and/or other materials provided with the distribution.
  11. THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
  12. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  13. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  14. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
  15. CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  16. EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  17. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  18. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
  19. OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  20. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  21. OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  22. */
  23. if(typeof(WScript) === "undefined")
  24. {
  25. var WScript = {
  26. Echo: print
  27. }
  28. }
  29. function record(time) {
  30. document.getElementById("console").innerHTML = time + "ms";
  31. if (window.parent) {
  32. parent.recordResult(time);
  33. }
  34. }
  35. var data =
  36. "{\"summary\":{\"turnover\":0.3736,\"correlation2\":0." +
  37. "7147,\"concentration\":0.3652,\"beta\":0.8814,\"totalValue\":1.3" +
  38. "091078259E8,\"correlation\":0.7217},\"watchlist\":[],\"shortCash" +
  39. "\":-1611000,\"holdings\":[{\"type\":\"LONG\",\"commission\":1040" +
  40. ",\"cost\":9001920,\"quantity\":26000,\"lots\":[{\"marketCap\":\"" +
  41. "L\",\"industry\":\"TECHNOLOGY\",\"style\":\"G\",\"buyDate\":\"20" +
  42. "08-10-08 13:44:20.000\",\"quantity\":8000},{\"marketCap\":\"L\"," +
  43. "\"industry\":\"TECHNOLOGY\",\"style\":\"G\",\"buyDate\":\"2008-1" +
  44. "0-15 13:28:02.000\",\"quantity\":18000}],\"stock\":\"GOOG\"},{\"" +
  45. "type\":\"LONG\",\"commission\":8000,\"cost\":4672000,\"quantity" +
  46. "\":200000,\"lots\":[{\"marketCap\":\"L\",\"industry\":\"TECHNOLO" +
  47. "GY\",\"style\":\"G\",\"buyDate\":\"2008-10-15 13:28:54.000\",\"q" +
  48. "uantity\":200000}],\"stock\":\"MSFT\"},{\"type\":\"LONG\",\"comm" +
  49. "ission\":21877,\"cost\":1.001592313E7,\"quantity\":546919,\"lots" +
  50. "\":[{\"marketCap\":\"L\",\"industry\":\"FINANCIAL\",\"style\":\"" +
  51. "G\",\"buyDate\":\"2008-08-01 09:50:17.000\",\"quantity\":103092}" +
  52. ",{\"marketCap\":\"L\",\"industry\":\"FINANCIAL\",\"style\":\"G\"" +
  53. ",\"buyDate\":\"2008-08-18 10:31:34.000\",\"quantity\":49950},{\"" +
  54. "marketCap\":\"L\",\"industry\":\"FINANCIAL\",\"style\":\"G\",\"b" +
  55. "uyDate\":\"2008-08-29 09:35:22.000\",\"quantity\":45045},{\"mark" +
  56. "etCap\":\"L\",\"industry\":\"FINANCIAL\",\"style\":\"G\",\"buyDa" +
  57. "te\":\"2008-09-15 09:40:32.000\",\"quantity\":48400},{\"marketCa" +
  58. "p\":\"L\",\"industry\":\"FINANCIAL\",\"style\":\"G\",\"buyDate\"" +
  59. ":\"2008-10-06 11:21:50.000\",\"quantity\":432},{\"marketCap\":\"" +
  60. "L\",\"industry\":\"FINANCIAL\",\"style\":\"G\",\"buyDate\":\"200" +
  61. "8-10-15 13:30:05.000\",\"quantity\":300000}],\"stock\":\"UBS\"}," +
  62. "{\"type\":\"LONG\",\"commission\":4000,\"cost\":6604849.1,\"quan" +
  63. "tity\":122741,\"lots\":[{\"marketCap\":\"L\",\"industry\":\"SERV" +
  64. "ICES\",\"style\":\"V\",\"buyDate\":\"2008-04-26 04:44:34.000\"," +
  65. "\"quantity\":22741},{\"marketCap\":\"L\",\"industry\":\"SERVICES" +
  66. "\",\"style\":\"V\",\"buyDate\":\"2008-10-15 13:31:02.000\",\"qua" +
  67. "ntity\":100000}],\"stock\":\"V\"},{\"type\":\"LONG\",\"commissio" +
  68. "n\":2805,\"cost\":5005558.25,\"quantity\":70121,\"lots\":[{\"mar" +
  69. "ketCap\":\"M\",\"industry\":\"RETAIL\",\"style\":\"G\",\"buyDate" +
  70. "\":\"2008-10-10 10:48:36.000\",\"quantity\":121},{\"marketCap\":" +
  71. "\"M\",\"industry\":\"RETAIL\",\"style\":\"G\",\"buyDate\":\"2008" +
  72. "-10-15 13:33:44.000\",\"quantity\":70000}],\"stock\":\"LDG\"},{" +
  73. "\"type\":\"LONG\",\"commission\":10000,\"cost\":5382500,\"quanti" +
  74. "ty\":250000,\"lots\":[{\"marketCap\":\"L\",\"industry\":\"RETAIL" +
  75. "\",\"style\":\"V\",\"buyDate\":\"2008-10-15 13:34:30.000\",\"qua" +
  76. "ntity\":250000}],\"stock\":\"SWY\"},{\"type\":\"LONG\",\"commiss" +
  77. "ion\":1120,\"cost\":1240960,\"quantity\":28000,\"lots\":[{\"mark" +
  78. "etCap\":\"u\",\"industry\":\"ETF\",\"style\":\"B\",\"buyDate\":" +
  79. "\"2008-10-15 15:57:39.000\",\"quantity\":28000}],\"stock\":\"OIL" +
  80. "\"},{\"type\":\"LONG\",\"commission\":400,\"cost\":236800,\"quan" +
  81. "tity\":10000,\"lots\":[{\"marketCap\":\"M\",\"industry\":\"UTILI" +
  82. "TIES_AND_ENERGY\",\"style\":\"G\",\"buyDate\":\"2008-10-15 15:58" +
  83. ":03.000\",\"quantity\":10000}],\"stock\":\"COG\"},{\"type\":\"LO" +
  84. "NG\",\"commission\":3200,\"cost\":1369600,\"quantity\":80000,\"l" +
  85. "ots\":[{\"marketCap\":\"S\",\"industry\":\"UTILITIES_AND_ENERGY" +
  86. "\",\"style\":\"G\",\"buyDate\":\"2008-10-15 15:58:32.000\",\"qua" +
  87. "ntity\":80000}],\"stock\":\"CRZO\"},{\"type\":\"LONG\",\"commiss" +
  88. "ion\":429,\"cost\":108164.8,\"quantity\":10720,\"lots\":[{\"mark" +
  89. "etCap\":\"u\",\"industry\":\"FINANCIAL\",\"style\":\"V\",\"buyDa" +
  90. "te\":\"2008-10-16 09:37:06.000\",\"quantity\":10720}],\"stock\":" +
  91. "\"FGI\"},{\"type\":\"LONG\",\"commission\":1080,\"cost\":494910," +
  92. "\"quantity\":27000,\"lots\":[{\"marketCap\":\"L\",\"industry\":" +
  93. "\"RETAIL\",\"style\":\"V\",\"buyDate\":\"2008-10-16 09:37:06.000" +
  94. "\",\"quantity\":27000}],\"stock\":\"LOW\"},{\"type\":\"LONG\",\"" +
  95. "commission\":4080,\"cost\":4867440,\"quantity\":102000,\"lots\":" +
  96. "[{\"marketCap\":\"L\",\"industry\":\"HEALTHCARE\",\"style\":\"V" +
  97. "\",\"buyDate\":\"2008-10-16 09:37:06.000\",\"quantity\":102000}]" +
  98. ",\"stock\":\"AMGN\"},{\"type\":\"SHORT\",\"commission\":4000,\"" +
  99. "cost\":-1159000,\"quantity\":-100000,\"lots\":[{\"marketCap\":" +
  100. "\"L\",\"industry\":\"TECHNOLOGY\",\"style\":\"V\",\"buyDate\":" +
  101. "\"2008-10-16 09:37:06.000\",\"quantity\":-100000}],\"stock\":\"" +
  102. "AMAT\"},{\"type\":\"LONG\",\"commission\":2,\"cost\":5640002,\"" +
  103. "quantity\":50,\"lots\":[{\"marketCap\":\"L\",\"industry\":\"FIN" +
  104. "ANCIAL\",\"style\":\"B\",\"buyDate\":\"2008-10-16 09:37:06.000" +
  105. "\",\"quantity\":50}],\"stock\":\"BRKA\"},{\"type\":\"SHORT\",\"" +
  106. "commission\":4000,\"cost\":-436000,\"quantity\":-100000,\"lots" +
  107. "\":[{\"marketCap\":\"M\",\"industry\":\"TRANSPORTATION\",\"styl" +
  108. "e\":\"G\",\"buyDate\":\"2008-10-16 09:37:06.000\",\"quantity\":-" +
  109. "100000}],\"stock\":\"JBLU\"},{\"type\":\"LONG\",\"commission\":8" +
  110. "000,\"cost\":1.1534E7,\"quantity\":200000,\"lots\":[{\"marketCap" +
  111. "\":\"S\",\"industry\":\"FINANCIAL\",\"style\":\"G\",\"buyDate\":" +
  112. "\"2008-10-16 14:35:24.000\",\"quantity\":200000}],\"stock\":\"US" +
  113. "O\"},{\"type\":\"LONG\",\"commission\":4000,\"cost\":1.0129E7,\"" +
  114. "quantity\":100000,\"lots\":[{\"marketCap\":\"L\",\"industry\":\"" +
  115. "TECHNOLOGY\",\"style\":\"G\",\"buyDate\":\"2008-10-15 13:28:26.0" +
  116. "00\",\"quantity\":50000},{\"marketCap\":\"L\",\"industry\":\"TEC" +
  117. "HNOLOGY\",\"style\":\"G\",\"buyDate\":\"2008-10-17 09:33:09.000" +
  118. "\",\"quantity\":50000}],\"stock\":\"AAPL\"},{\"type\":\"LONG\"," +
  119. "\"commission\":1868,\"cost\":9971367.2,\"quantity\":54280,\"lots" +
  120. "\":[{\"marketCap\":\"L\",\"industry\":\"SERVICES\",\"style\":\"G" +
  121. "\",\"buyDate\":\"2008-04-26 04:44:34.000\",\"quantity\":7580},{" +
  122. "\"marketCap\":\"L\",\"industry\":\"SERVICES\",\"style\":\"G\",\"" +
  123. "buyDate\":\"2008-05-29 09:50:28.000\",\"quantity\":7500},{\"mark" +
  124. "etCap\":\"L\",\"industry\":\"SERVICES\",\"style\":\"G\",\"buyDat" +
  125. "e\":\"2008-10-15 13:30:38.000\",\"quantity\":33000},{\"marketCap" +
  126. "\":\"L\",\"industry\":\"SERVICES\",\"style\":\"G\",\"buyDate\":" +
  127. "\"2008-10-17 09:33:09.000\",\"quantity\":6200}],\"stock\":\"MA\"" +
  128. "}],\"longCash\":4.600368106E7,\"ownerId\":8,\"pendingOrders\":[{" +
  129. "\"total\":487000,\"type\":\"cover\",\"subtotal\":483000,\"price" +
  130. "\":4.83,\"commission\":4000,\"date\":\"2008-10-17 23:56:06.000\"" +
  131. ",\"quantity\":100000,\"expires\":\"2008-10-20 16:00:00.000\",\"s" +
  132. "tock\":\"JBLU\",\"id\":182375},{\"total\":6271600,\"type\":\"buy" +
  133. "\",\"subtotal\":6270000,\"price\":156.75,\"commission\":1600,\"d" +
  134. "ate\":\"2008-10-17 23:56:40.000\",\"quantity\":40000,\"expires\"" +
  135. ":\"2008-10-20 16:00:00.000\",\"stock\":\"MA\",\"id\":182376}],\"" +
  136. "inceptionDate\":\"2008-04-26 04:44:29.000\",\"withdrawals\":0,\"" +
  137. "id\":219948,\"deposits\":0}";
  138. var _sunSpiderStartDate = new Date();
  139. for (var i = 0; i < 1000; i++) {
  140. var x = JSON.parse(data);
  141. }
  142. var _sunSpiderInterval = new Date() - _sunSpiderStartDate;
  143. WScript.Echo("### TIME:", _sunSpiderInterval, "ms");