Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9)

Side by Side Diff: ppapi/proxy/ppp_messaging_proxy_perftest.cc

Issue 9195029: Add ppapi perftests infrastructure, plus a performance test for PPP_Messaging. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: tweaks Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "base/command_line.h"
6 #include "base/perftimer.h"
7 #include "base/string_number_conversions.h"
8 #include "ppapi/c/ppp_messaging.h"
9 #include "ppapi/proxy/ppapi_proxy_test.h"
10 #include "ppapi/proxy/serialized_var.h"
11 #include "ppapi/shared_impl/ppapi_globals.h"
12 #include "ppapi/shared_impl/var.h"
13 #include "ppapi/shared_impl/var_tracker.h"
14
15 namespace ppapi {
16 namespace proxy {
17 namespace {
18
19 base::WaitableEvent handle_message_called(false, false);
20
21 void HandleMessage(PP_Instance /* instance */, PP_Var /* message_data */) {
22 handle_message_called.Signal();
23 }
24
25 PPP_Messaging ppp_messaging_mock = {
26 &HandleMessage
27 };
28
29 class PppMessagingPerfTest : public TwoWayTest {
30 public:
31 PppMessagingPerfTest() : TwoWayTest(TwoWayTest::TEST_PPP_INTERFACE) {
32 plugin().RegisterTestInterface(PPP_MESSAGING_INTERFACE,
33 &ppp_messaging_mock);
34 }
35 };
36
37 } // namespace
38
39 // Tests the performance of sending strings through the proxy.
40 TEST_F(PppMessagingPerfTest, StringPerformance) {
41 // Grab the host-side proxy of ppp_messaging.
42 const PPP_Messaging* ppp_messaging = static_cast<const PPP_Messaging*>(
43 host().host_dispatcher()->GetProxiedInterface(
44 PPP_MESSAGING_INTERFACE));
45 const PP_Instance kTestInstance = pp_instance();
46 int string_size = 100000;
47 int string_count = 1000;
48 CommandLine* command_line = CommandLine::ForCurrentProcess();
49 if (command_line) {
50 if (command_line->HasSwitch("string_size")) {
51 base::StringToInt(command_line->GetSwitchValueASCII("string_size"),
52 &string_size);
53 }
54 if (command_line->HasSwitch("string_count")) {
55 base::StringToInt(command_line->GetSwitchValueASCII("string_count"),
56 &string_count);
57 }
58 }
59 // Make a string var of size string_size.
60 const std::string kTestString(string_size, 'a');
61 PP_Var host_string = StringVar::StringToPPVar(kTestString);
piman 2012/01/20 17:39:23 TBH, if you truly want to measure the cost of send
dmichael (off chromium) 2012/01/20 17:53:20 I thought about doing it that way, but I decided t
62 PerfTimeLogger logger("PppMessagingPerfTest.StringPerformance");
63 for (int i = 0; i < string_count; ++i) {
64 ppp_messaging->HandleMessage(kTestInstance, host_string);
65 handle_message_called.Wait();
66 }
67 PpapiGlobals::Get()->GetVarTracker()->ReleaseVar(host_string);
68 }
69
70 } // namespace proxy
71 } // namespace ppapi
72
OLDNEW
« ppapi/proxy/ppapi_perftests.cc ('K') | « ppapi/proxy/ppapi_perftests.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698