Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. <html>
  2. <head>
  3. <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
  4. <script>
  5. $(document).ready(function()
  6. {
  7. var count = 1;
  8. var loop = 0;
  9.  
  10. var userRead = 0;
  11. var mainRead =0;
  12. var commentRead = 0;
  13. var totalReps = 0;
  14. var currentKey ="";
  15.  
  16. var d = new Date();
  17. var t_hour = d.getHours();    
  18. var t_min = d.getMinutes();  
  19. var t_sec = d.getSeconds();  
  20. var sTime = d.getTime();
  21. var eTime = 0;
  22. $('#res').hide();
  23. $('#hs').click(function() {
  24.   $('#res').toggle('slow');
  25. });
  26.  
  27. $('#time').html("Start " + t_hour + ":" + t_min + ":" + t_sec + " - ");
  28. doLoop();
  29.  
  30. function doLoop()
  31. {
  32.     loop++;
  33.     if(userRead == 0)
  34.     {
  35.         doUserRead();
  36.     }
  37.     else if(mainRead == 0)
  38.     {
  39.         doMainRead();
  40.     }
  41.     else
  42.     {
  43.         if(commentRead < 50)
  44.         {
  45.             doCommentRead();
  46.             commentRead++;
  47.         }
  48.         else if(commentRead == 50)
  49.         {
  50.             userRead = 0;
  51.             mainRead =0;
  52.             commentRead = 0;
  53.             if(totalReps ==0)
  54.             {  
  55.                 currentKey = getRandString(8, 25);
  56.                 $('#cKey').html("created " + currentKey);
  57.                 cfTwoInsert(currentKey);           
  58.                 totalReps++;
  59.             }
  60.             else if(totalReps == 1)
  61.             {
  62.                 $('#cKey').html("<b>deleted</b> " + currentKey);
  63.                 var q = document.location.href + "testKeyspace/testCF2/"+currentKey+"////QUORUM";
  64.                 doDELETE(q);   
  65.                 totalReps++;
  66.             }
  67.             else if(totalReps == 2)
  68.             {
  69.                 var d = new Date();
  70.                 var t_hour = d.getHours();    
  71.                 var t_min = d.getMinutes();  
  72.                 var t_sec = d.getSeconds();
  73.                 eTime = d.getTime();  
  74.                 $('#time').append("Stop " + t_hour + ":" + t_min + ":" + t_sec + "<br /> ");
  75.                 $('#time').append(sTime + " " + eTime);
  76.             }
  77.         }
  78.     }  
  79.     $("#count").html(loop);
  80. }
  81.  
  82. function doUserRead()
  83. {
  84.         var keyNum = Math.floor(Math.random()*1999);
  85.         keyNum ++;
  86.         var key = "testKey" + keyNum;  
  87.         var q =  document.location.href + "testKeyspace/testCF3/"+key+"////QUORUM.plain";
  88.         userRead = 1;
  89.         doGET(q);      
  90. }
  91.  
  92. function doMainRead()
  93. {
  94.         var keyNum = Math.floor(Math.random()*1498);
  95.         keyNum ++;
  96.         var key = "testKey" + keyNum;
  97.         var q =  document.location.href + "testKeyspace/testCF1/"+key+"////QUORUM.plain";
  98.         mainRead = 1;
  99.         doGET(q);      
  100. }
  101.  
  102. function doCommentRead()
  103. {
  104.         var keyNum = Math.floor(Math.random()*2999);
  105.         keyNum ++;
  106.         var key = "testKey" + keyNum;
  107.         var q =  document.location.href + "testKeyspace/testCF2/"+key+"////QUORUM.plain";
  108.         doGET(q);      
  109. }
  110.  
  111. function getRandString(maxLen, minLen)
  112. {
  113.     var rndString ="";
  114.     var len = Math.random()*((maxLen-minLen)); 
  115.     len = Math.floor(minLen+len);
  116.     var generator; 
  117.     for(var i = 0; i < len; i++)
  118.     {
  119.         generator = Math.random()*(25);
  120.         generator = Math.floor(65+generator);
  121.         rndString = rndString + String.fromCharCode(generator);
  122.     }  
  123.     return rndString;
  124. }
  125.  
  126. function getRandDate()
  127. {
  128.     var day = (Math.floor(Math.random()*((28)))) + 1;
  129.     var month = (Math.floor(Math.random()*((11)))) + 1;
  130.     return day + "/" + month + "/2010";
  131. }
  132.  
  133.  
  134. function cfOneInsert(rowKey)
  135. {
  136.     var title = getRandString(20, 45);
  137.     var text = getRandString(40, 60);
  138.     var score = (Math.floor(Math.random()*((1000)))) + 1; /*1 - 1001 */
  139.     var date = getRandDate();
  140.  
  141.     /*var rowKey = "testKey" + count;*/
  142.     var q =  document.location.href + "testKeyspace/testCF1/"+rowKey+"////QUORUM"; 
  143.  
  144.     var POSTData = encodeURIComponent("title") + "=" + encodeURIComponent(title);
  145.     POSTData = POSTData + "&" + encodeURIComponent("text") + "=" + encodeURIComponent(text);
  146.     POSTData = POSTData + "&" + encodeURIComponent("score") + "=" + encodeURIComponent(score);
  147.     POSTData = POSTData + "&" + encodeURIComponent("date") + "=" + encodeURIComponent(date);
  148.  
  149.     $("#result").append(q + " " + POSTData + "\n\n");
  150.     doPOST(q, POSTData);
  151.     count++;
  152. }
  153.  
  154. function cfTwoInsert(rowKey)
  155. {
  156.     var comment = getRandString(30, 45);
  157.     var username = getRandString(6, 15);
  158.     var date = getRandDate();
  159.  
  160.     /*var rowKey = "testKey" + count;*/
  161.     var q =  document.location.href + "testKeyspace/testCF2/"+rowKey+"////QUORUM"; 
  162.  
  163.     var POSTData = encodeURIComponent("comment") + "=" + encodeURIComponent(comment);
  164.     POSTData = POSTData + "&" + encodeURIComponent("username") + "=" + encodeURIComponent(username);
  165.     POSTData = POSTData + "&" + encodeURIComponent("date") + "=" + encodeURIComponent(date);
  166.  
  167.     $("#result").prepend(q + " " + POSTData + "\n\n");
  168.     doPOST(q, POSTData);
  169.     count++;
  170. }
  171.  
  172. function cfThreeInsert(rowKey)
  173. {
  174.     var username = getRandString(30, 45);
  175.     var password = getRandString(6, 15);
  176.     var firstName = getRandString(6, 25);
  177.     var lastName = getRandString(6, 25);
  178.     var email = getRandString(6, 15) + "@" + getRandString(5, 9) +".com";
  179.  
  180.     /*var rowKey = "testKey" + count;*/
  181.     var q =  document.location.href + "testKeyspace/testCF3/"+rowKey+"////QUORUM"; 
  182.  
  183.     var POSTData = encodeURIComponent("username") + "=" + encodeURIComponent(username);
  184.     POSTData = POSTData + "&" + encodeURIComponent("firstName") + "=" + encodeURIComponent(firstName);
  185.     POSTData = POSTData + "&" + encodeURIComponent("lastName") + "=" + encodeURIComponent(lastName);
  186.     POSTData = POSTData + "&" + encodeURIComponent("email") + "=" + encodeURIComponent(email);
  187.  
  188.     $("#result").prepend(POSTData + "\n\n");
  189.     doPOST(q, POSTData);
  190.     count++;
  191. }
  192.  
  193. function doPOST(q, data)
  194. {
  195.     $.ajax({
  196.     url: q,
  197.     type: "POST",
  198.     data: data,
  199.     dataType: "html",
  200.     statusCode:
  201.     {
  202.         404:function() { $("#error").html("404 - Not Found");},
  203.         400:function() { $("#error").html("400 - Bad Request"); },
  204.         413:function() { $("#error").html("413 - 413 Request Entity Too Large"); },
  205.         415:function() { $("#error").html("415 - Unsupported media type"); },
  206.         500:function() { $("#error").html("500 - Internal Server Error"); }
  207.     },
  208.     success: function(data)
  209.     {
  210.         $('#result').prepend("POST :\n" + data + "\n");
  211.         doLoop();
  212.     }
  213.     });
  214. }
  215.  
  216. function doGET(q)
  217. {
  218.     $.ajax({
  219.         url: q,
  220.         type: "GET",
  221.         dataType: "html",
  222.         statusCode: {
  223.         404:function() { $("#error").html("404 - Not Found" + q);},
  224.         400:function() { $("#error").html("400 - Bad Request"+ q); },
  225.         413:function() { $("#error").html("413 - 413 Request Entity Too Large"+ q); },
  226.         415:function() { $("#error").html("415 - Unsupported media type"+ q); },
  227.         500:function() { $("#error").html("500 - Internal Server Error"+ q); }
  228.         },
  229.         success: function(data)
  230.         {
  231.             $('#result').prepend("GET :\n" + data + "\n");
  232.             doLoop();
  233.  
  234.         }
  235.         });
  236. }
  237.  
  238. function doDELETE(q)
  239. {
  240.     $.ajax({
  241.         url: q,
  242.         type: "DELETE",
  243.         dataType: "html",
  244.         statusCode: {
  245.         404:function() { $("#error").html("404 - Not Found" + q);},
  246.         400:function() { $("#error").html("400 - Bad Request"+ q); },
  247.         413:function() { $("#error").html("413 - 413 Request Entity Too Large"+ q); },
  248.         415:function() { $("#error").html("415 - Unsupported media type"+ q); },
  249.         500:function() { $("#error").html("500 - Internal Server Error"+ q); }
  250.         },
  251.  
  252.         success: function(data)
  253.  
  254.         {
  255.             $('#result').prepend("DELETE :\n" + data + "\n");
  256.             doLoop();
  257.         }
  258.     });
  259.  
  260. }
  261.  
  262.  
  263. });
  264.  
  265. </script>
  266.  
  267. </head>
  268. <body>
  269.  
  270. <h1>Thanks for running my test</h1>
  271. <p>It doesnt look like much, but there is lots going on in the background. If you want to know what your computer is doing for the test, read <a href="">This</a></p>
  272. <p>This page will 'refresh' every ~60 seconds</p>
  273. <input type="button" id="hs" value="show/hide console"/>
  274. <div id ="res">
  275.     <textarea id="result" style="Width:1000px; height: 350px; border:none; padding: 10px;" > </textarea>
  276.     <br />
  277.     <br />
  278.     <div id="time"> </div>
  279. <div id="error" style="font-weight:bold;">  </div>
  280. <div id="cKey"> </div>
  281. </div>
  282. <br />
  283. <p>Requests done: </p>
  284. <h3 id="count"></h3>
  285.  
  286.  
  287.  
  288. </body>
  289.  
  290. </html>