PerformanceTest.pl 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. #!/usr/bin/perl
  2. # Usage:
  3. # ./PerformanceTest.pl
  4. # 2 variables should be changed:
  5. # Line 14: $fork_limit
  6. # Line 13: $benchmark_loop_count
  7. #
  8. use strict;
  9. use OpenSimTest;
  10. my $script = "./PerformanceTest.pl";
  11. my $fork_limit = 50; # the number of process
  12. my $benchmark_loop_count = 10000; # the number of requests sent by each process
  13. my @child_pid = ();
  14. for(1..$fork_limit) {
  15. my $pid = fork;
  16. if ($pid) {
  17. &parent_do($pid);
  18. } elsif ($pid == 0) {
  19. &child_do;
  20. exit(0);
  21. } else {
  22. die "could not fork";
  23. }
  24. }
  25. foreach (@child_pid) {
  26. waitpid($_, 0);
  27. }
  28. sub parent_do {
  29. my $pid = shift;
  30. push(@child_pid, $pid);
  31. }
  32. sub child_do {
  33. #for(1..10000) {
  34. # print "$_ ";
  35. #}
  36. &OpenSimTest::init();
  37. # user
  38. &OpenSimTest::PerformanceCompare("user", $benchmark_loop_count, "get_user_by_name", "Test User");
  39. &OpenSimTest::PerformanceCompare("user", $benchmark_loop_count, "get_user_by_uuid", "db836502-de98-49c9-9edc-b90a67beb0a8");
  40. # grid
  41. &OpenSimTest::PerformanceCompare("grid", $benchmark_loop_count, "simulator_login", "3507f395-88e5-468c-a45f-d4fd96a1c668", "10.8.1.148", 9000);
  42. &OpenSimTest::PerformanceCompare("grid", $benchmark_loop_count, "simulator_data_request", "1099511628032000");
  43. &OpenSimTest::PerformanceCompare("grid", $benchmark_loop_count, "map_block", 999, 999, 1001, 1001);
  44. # asset
  45. &OpenSimTest::PerformanceCompare("asset", $benchmark_loop_count, "get_asset", "00000000000022223333000000000001");
  46. # inventory
  47. &OpenSimTest::PerformanceCompare("inventory", $benchmark_loop_count, "root_folders", "b9cb58e8-f3c9-4af5-be47-029762baa68f");
  48. &OpenSimTest::PerformanceCompare("inventory", $benchmark_loop_count, "get_inventory", "b9cb58e8-f3c9-4af5-be47-029762baa68f");
  49. }
  50. __END__
  51. my $count = 10000;
  52. &OpenSimTest::init();
  53. # user
  54. #&OpenSimTest::PerformanceCompare("user", $count, "get_user_by_name", "Test User");
  55. #&OpenSimTest::PerformanceCompare("user", $count, "get_user_by_uuid", "db836502-de98-49c9-9edc-b90a67beb0a8");
  56. # grid
  57. #&OpenSimTest::PerformanceCompare("grid", $count, "simulator_login", "3507f395-88e5-468c-a45f-d4fd96a1c668", "10.8.1.148", 9000);
  58. #&OpenSimTest::PerformanceCompare("grid", $count, "simulator_data_request", "1099511628032000");
  59. #&OpenSimTest::PerformanceCompare("grid", $count, "map_block", 999, 999, 1001, 1001);
  60. # asset
  61. &OpenSimTest::PerformanceCompare("asset", $count, "get_asset", "00000000000022223333000000000001");
  62. # inventory
  63. #&OpenSimTest::PerformanceCompare("inventory", $count, "create_inventory", "b9cb58e8-f3c9-4af5-be47-029762baa68f");
  64. #&OpenSimTest::PerformanceCompare("inventory", $count, "root_folders", "b9cb58e8-f3c9-4af5-be47-029762baa68f");
  65. #&OpenSimTest::PerformanceCompare("inventory", $count, "get_inventory", "b9cb58e8-f3c9-4af5-be47-029762baa68f");
  66. #&OpenSimTest::PerformanceCompare("inventory", $count, "new_item");
  67. #&OpenSimTest::PerformanceCompare("inventory", $count, "new_folder");