BenchAction.class.php 884 B

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. // This class automatically generated by the System, for testing purposes
  3. class BenchAction extends Action {
  4. public function rawjson() {
  5. header('Content-type: application/json');
  6. die(json_encode(array('message' => 'Hello World!')));
  7. }
  8. public function rawdb() {
  9. $query_count = (int) $this->_request('queries');
  10. if (0 >= $query_count) {
  11. $query_count = 1;
  12. } elseif (500 < $query_count) {
  13. $query_count = 500;
  14. }
  15. $arr = array();
  16. $World = M('World');
  17. while (0 < $query_count--) {
  18. $id = mt_rand(1, 10000);
  19. $d = $World->find($id);
  20. $arr[] = $d;
  21. }
  22. header('Content-type: application/json');
  23. die(json_encode($arr));
  24. }
  25. public function rawfortunes() {
  26. $Fortunes = M('Fortune');
  27. $this->data = $Fortunes->select();
  28. $this->display();
  29. }
  30. }