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

Unified Diff: ppapi/proxy/ppp_messaging_proxy_perftest.cc

Issue 9138027: PPAPI: Reduce string copying in SerializedVar. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Duh 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ppapi/proxy/plugin_var_serialization_rules.cc ('k') | ppapi/proxy/serialized_var.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ppapi/proxy/ppp_messaging_proxy_perftest.cc
diff --git a/ppapi/proxy/ppp_messaging_proxy_perftest.cc b/ppapi/proxy/ppp_messaging_proxy_perftest.cc
index a58b025763cdc9fdf11ddfa0e823b647aecc4b67..ecdeb1252370ed619e57f11b400b57a352d49417 100644
--- a/ppapi/proxy/ppp_messaging_proxy_perftest.cc
+++ b/ppapi/proxy/ppp_messaging_proxy_perftest.cc
@@ -29,6 +29,7 @@ void HandleMessage(PP_Instance /* instance */, PP_Var message_data) {
// Do something simple with the string so the compiler won't complain.
if (s.length() > 0)
s[0] = 'a';
+ PpapiGlobals::Get()->GetVarTracker()->ReleaseVar(message_data);
handle_message_called.Signal();
}
@@ -53,24 +54,29 @@ TEST_F(PppMessagingPerfTest, StringPerformance) {
host().host_dispatcher()->GetProxiedInterface(
PPP_MESSAGING_INTERFACE));
const PP_Instance kTestInstance = pp_instance();
- int string_size = 100000;
+ int seed = 123;
int string_count = 1000;
+ int max_string_size = 1000000;
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("seed")) {
+ base::StringToInt(command_line->GetSwitchValueASCII("seed"),
+ &seed);
}
if (command_line->HasSwitch("string_count")) {
base::StringToInt(command_line->GetSwitchValueASCII("string_count"),
&string_count);
}
+ if (command_line->HasSwitch("max_string_size")) {
+ base::StringToInt(command_line->GetSwitchValueASCII("max_string_size"),
+ &max_string_size);
+ }
}
- // Make a string var of size string_size.
- const std::string kTestString(string_size, 'a');
+ srand(seed);
PerfTimeLogger logger("PppMessagingPerfTest.StringPerformance");
for (int i = 0; i < string_count; ++i) {
- PP_Var host_string = StringVar::StringToPPVar(kTestString);
+ const std::string test_string(rand() % max_string_size, 'a');
+ PP_Var host_string = StringVar::StringToPPVar(test_string);
ppp_messaging->HandleMessage(kTestInstance, host_string);
handle_message_called.Wait();
PpapiGlobals::Get()->GetVarTracker()->ReleaseVar(host_string);
« no previous file with comments | « ppapi/proxy/plugin_var_serialization_rules.cc ('k') | ppapi/proxy/serialized_var.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698