Commit 433c2212 authored by dmichael@chromium.org's avatar dmichael@chromium.org

PPAPI: Revive ppp_messaging_proxy_perftest

This test can measure PPP_Messaging performance and indirectly IPC
performance. It regressed due to a couple of minor changes; this
gets it running again.

BUG=

Review URL: https://codereview.chromium.org/453003002

Cr-Commit-Position: refs/heads/master@{#288433}
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@288433 0039d316-1c4b-4281-b951-d872f2087c98
parent a8162665
...@@ -6,9 +6,11 @@ ...@@ -6,9 +6,11 @@
#include "base/strings/string_number_conversions.h" #include "base/strings/string_number_conversions.h"
#include "base/test/perf_time_logger.h" #include "base/test/perf_time_logger.h"
#include "ppapi/c/ppp_messaging.h" #include "ppapi/c/ppp_messaging.h"
#include "ppapi/proxy/ppapi_messages.h"
#include "ppapi/proxy/ppapi_proxy_test.h" #include "ppapi/proxy/ppapi_proxy_test.h"
#include "ppapi/proxy/serialized_var.h" #include "ppapi/proxy/serialized_var.h"
#include "ppapi/shared_impl/ppapi_globals.h" #include "ppapi/shared_impl/ppapi_globals.h"
#include "ppapi/shared_impl/proxy_lock.h"
#include "ppapi/shared_impl/var.h" #include "ppapi/shared_impl/var.h"
#include "ppapi/shared_impl/var_tracker.h" #include "ppapi/shared_impl/var_tracker.h"
...@@ -19,6 +21,7 @@ namespace { ...@@ -19,6 +21,7 @@ namespace {
base::WaitableEvent handle_message_called(false, false); base::WaitableEvent handle_message_called(false, false);
void HandleMessage(PP_Instance /* instance */, PP_Var message_data) { void HandleMessage(PP_Instance /* instance */, PP_Var message_data) {
ppapi::ProxyAutoLock lock;
StringVar* string_var = StringVar::FromPPVar(message_data); StringVar* string_var = StringVar::FromPPVar(message_data);
DCHECK(string_var); DCHECK(string_var);
// Retrieve the string to make sure the proxy can't "optimize away" sending // Retrieve the string to make sure the proxy can't "optimize away" sending
...@@ -49,10 +52,6 @@ class PppMessagingPerfTest : public TwoWayTest { ...@@ -49,10 +52,6 @@ class PppMessagingPerfTest : public TwoWayTest {
// Tests the performance of sending strings through the proxy. // Tests the performance of sending strings through the proxy.
TEST_F(PppMessagingPerfTest, StringPerformance) { 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(); const PP_Instance kTestInstance = pp_instance();
int seed = 123; int seed = 123;
int string_count = 1000; int string_count = 1000;
...@@ -77,7 +76,13 @@ TEST_F(PppMessagingPerfTest, StringPerformance) { ...@@ -77,7 +76,13 @@ TEST_F(PppMessagingPerfTest, StringPerformance) {
for (int i = 0; i < string_count; ++i) { for (int i = 0; i < string_count; ++i) {
const std::string test_string(rand() % max_string_size, 'a'); const std::string test_string(rand() % max_string_size, 'a');
PP_Var host_string = StringVar::StringToPPVar(test_string); PP_Var host_string = StringVar::StringToPPVar(test_string);
ppp_messaging->HandleMessage(kTestInstance, host_string); // We don't have a host-side PPP_Messaging interface; just send the message
// directly like the proxy does.
host().host_dispatcher()->Send(new PpapiMsg_PPPMessaging_HandleMessage(
ppapi::API_ID_PPP_MESSAGING,
kTestInstance,
ppapi::proxy::SerializedVarSendInput(host().host_dispatcher(),
host_string)));
handle_message_called.Wait(); handle_message_called.Wait();
PpapiGlobals::Get()->GetVarTracker()->ReleaseVar(host_string); PpapiGlobals::Get()->GetVarTracker()->ReleaseVar(host_string);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment