summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordmichael@chromium.org <dmichael@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-24 20:29:04 +0000
committerdmichael@chromium.org <dmichael@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-24 20:29:04 +0000
commit514e2ce17d4d365c9824f13b537d3f12efe03ba8 (patch)
treef6277b4cedf6ab6db99473a91b1c21e883783b12
parenta749350b45331bbe787e9b8d5d61a9cee7c07131 (diff)
downloadchromium_src-514e2ce17d4d365c9824f13b537d3f12efe03ba8.zip
chromium_src-514e2ce17d4d365c9824f13b537d3f12efe03ba8.tar.gz
chromium_src-514e2ce17d4d365c9824f13b537d3f12efe03ba8.tar.bz2
Add ppapi perftests infrastructure, plus a performance test for PPP_Messaging.
BUG= TEST= Review URL: http://codereview.chromium.org/9195029 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@118888 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--ppapi/ppapi_tests.gypi43
-rw-r--r--ppapi/proxy/ppapi_perftests.cc10
-rw-r--r--ppapi/proxy/ppp_messaging_proxy_perftest.cc82
3 files changed, 131 insertions, 4 deletions
diff --git a/ppapi/ppapi_tests.gypi b/ppapi/ppapi_tests.gypi
index 0e23631..6f915d6 100644
--- a/ppapi/ppapi_tests.gypi
+++ b/ppapi/ppapi_tests.gypi
@@ -118,6 +118,44 @@
# ],
},
{
+ 'target_name': 'ppapi_unittest_shared',
+ 'type': 'static_library',
+ 'dependencies': [
+ 'ppapi_proxy',
+ 'ppapi_shared',
+ '../base/base.gyp:test_support_base',
+ '../ipc/ipc.gyp:ipc',
+ '../ipc/ipc.gyp:test_support_ipc',
+ '../testing/gmock.gyp:gmock',
+ '../testing/gtest.gyp:gtest',
+ ],
+ 'sources': [
+ 'proxy/ppapi_proxy_test.cc',
+ 'proxy/ppapi_proxy_test.h',
+ 'shared_impl/test_globals.cc',
+ 'shared_impl/test_globals.h',
+ ],
+ },
+
+ {
+ 'target_name': 'ppapi_perftests',
+ 'type': 'executable',
+ 'variables': {
+ 'chromium_code': 1,
+ },
+ 'dependencies': [
+ 'ppapi_proxy',
+ 'ppapi_shared',
+ 'ppapi_unittest_shared',
+ '../base/base.gyp:test_support_base',
+ '../testing/gtest.gyp:gtest',
+ ],
+ 'sources': [
+ 'proxy/ppapi_perftests.cc',
+ 'proxy/ppp_messaging_proxy_perftest.cc',
+ ],
+ },
+ {
'target_name': 'ppapi_unittests',
'type': 'executable',
'variables': {
@@ -126,6 +164,7 @@
'dependencies': [
'ppapi_proxy',
'ppapi_shared',
+ 'ppapi_unittest_shared',
'../base/base.gyp:test_support_base',
'../gpu/gpu.gyp:gpu_ipc',
'../ipc/ipc.gyp:ipc',
@@ -142,16 +181,12 @@
'proxy/plugin_dispatcher_unittest.cc',
'proxy/plugin_resource_tracker_unittest.cc',
'proxy/plugin_var_tracker_unittest.cc',
- 'proxy/ppapi_proxy_test.cc',
- 'proxy/ppapi_proxy_test.h',
'proxy/ppb_var_unittest.cc',
'proxy/ppp_instance_private_proxy_unittest.cc',
'proxy/ppp_instance_proxy_unittest.cc',
'proxy/ppp_messaging_proxy_unittest.cc',
'proxy/serialized_var_unittest.cc',
'shared_impl/resource_tracker_unittest.cc',
- 'shared_impl/test_globals.cc',
- 'shared_impl/test_globals.h',
'shared_impl/tracked_callback_unittest.cc',
'shared_impl/var_tracker_unittest.cc',
],
diff --git a/ppapi/proxy/ppapi_perftests.cc b/ppapi/proxy/ppapi_perftests.cc
new file mode 100644
index 0000000..a9138e6
--- /dev/null
+++ b/ppapi/proxy/ppapi_perftests.cc
@@ -0,0 +1,10 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/test/perf_test_suite.h"
+
+int main(int argc, char** argv) {
+ return base::PerfTestSuite(argc, argv).Run();
+}
+
diff --git a/ppapi/proxy/ppp_messaging_proxy_perftest.cc b/ppapi/proxy/ppp_messaging_proxy_perftest.cc
new file mode 100644
index 0000000..a58b025
--- /dev/null
+++ b/ppapi/proxy/ppp_messaging_proxy_perftest.cc
@@ -0,0 +1,82 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/command_line.h"
+#include "base/perftimer.h"
+#include "base/string_number_conversions.h"
+#include "ppapi/c/ppp_messaging.h"
+#include "ppapi/proxy/ppapi_proxy_test.h"
+#include "ppapi/proxy/serialized_var.h"
+#include "ppapi/shared_impl/ppapi_globals.h"
+#include "ppapi/shared_impl/var.h"
+#include "ppapi/shared_impl/var_tracker.h"
+
+namespace ppapi {
+namespace proxy {
+namespace {
+
+base::WaitableEvent handle_message_called(false, false);
+
+void HandleMessage(PP_Instance /* instance */, PP_Var message_data) {
+ StringVar* string_var = StringVar::FromPPVar(message_data);
+ DCHECK(string_var);
+ // Retrieve the string to make sure the proxy can't "optimize away" sending
+ // the actual contents of the string (e.g., by doing a lazy retrieve or
+ // something). Note that this test is for performance only, and assumes
+ // other tests check for correctness.
+ std::string s = string_var->value();
+ // Do something simple with the string so the compiler won't complain.
+ if (s.length() > 0)
+ s[0] = 'a';
+ handle_message_called.Signal();
+}
+
+PPP_Messaging ppp_messaging_mock = {
+ &HandleMessage
+};
+
+class PppMessagingPerfTest : public TwoWayTest {
+ public:
+ PppMessagingPerfTest() : TwoWayTest(TwoWayTest::TEST_PPP_INTERFACE) {
+ plugin().RegisterTestInterface(PPP_MESSAGING_INTERFACE,
+ &ppp_messaging_mock);
+ }
+};
+
+} // namespace
+
+// Tests the performance of sending strings through the proxy.
+TEST_F(PppMessagingPerfTest, StringPerformance) {
+ // Grab the host-side proxy of ppp_messaging.
+ const PPP_Messaging* ppp_messaging = static_cast<const PPP_Messaging*>(
+ host().host_dispatcher()->GetProxiedInterface(
+ PPP_MESSAGING_INTERFACE));
+ const PP_Instance kTestInstance = pp_instance();
+ int string_size = 100000;
+ int string_count = 1000;
+ CommandLine* command_line = CommandLine::ForCurrentProcess();
+ if (command_line) {
+ if (command_line->HasSwitch("string_size")) {
+ base::StringToInt(command_line->GetSwitchValueASCII("string_size"),
+ &string_size);
+ }
+ if (command_line->HasSwitch("string_count")) {
+ base::StringToInt(command_line->GetSwitchValueASCII("string_count"),
+ &string_count);
+ }
+ }
+ // Make a string var of size string_size.
+ const std::string kTestString(string_size, 'a');
+ PerfTimeLogger logger("PppMessagingPerfTest.StringPerformance");
+ for (int i = 0; i < string_count; ++i) {
+ PP_Var host_string = StringVar::StringToPPVar(kTestString);
+ ppp_messaging->HandleMessage(kTestInstance, host_string);
+ handle_message_called.Wait();
+ PpapiGlobals::Get()->GetVarTracker()->ReleaseVar(host_string);
+ }
+}
+
+} // namespace proxy
+} // namespace ppapi
+