Commit 3ae73738 authored by mseaborn's avatar mseaborn Committed by Commit bot

PNaCl cleanup: Convert most uses of NaClGetTimeOfDayMicroseconds()

Use the timer interface from base/ instead.

This removes a dependency on nacl_time.h from native_client/, which is
#included indirectly in utility.h.

I tested this manually by adding some logging to print the times, and
I checked that they're roughly the same before and after the change
when running NaClBrowserTestPnacl.PPAPICore (which tests PNaCl
translation).

BUG= https://bugs.chromium.org/p/nativeclient/issues/detail?id=2832
TEST=see above

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

Cr-Commit-Position: refs/heads/master@{#371823}
parent 73eb7a19
...@@ -371,7 +371,7 @@ pp::CompletionCallback PnaclCoordinator::GetCompileProgressCallback( ...@@ -371,7 +371,7 @@ pp::CompletionCallback PnaclCoordinator::GetCompileProgressCallback(
void PnaclCoordinator::LoadCompiler() { void PnaclCoordinator::LoadCompiler() {
PLUGIN_PRINTF(("PnaclCoordinator::LoadCompiler")); PLUGIN_PRINTF(("PnaclCoordinator::LoadCompiler"));
int64_t compiler_load_start_time = NaClGetTimeOfDayMicroseconds(); base::TimeTicks compiler_load_start_time = base::TimeTicks::Now();
pp::CompletionCallback load_finished = callback_factory_.NewCallback( pp::CompletionCallback load_finished = callback_factory_.NewCallback(
&PnaclCoordinator::RunCompile, compiler_load_start_time); &PnaclCoordinator::RunCompile, compiler_load_start_time);
PnaclResources::ResourceType compiler_type = pnacl_options_.use_subzero PnaclResources::ResourceType compiler_type = pnacl_options_.use_subzero
...@@ -385,7 +385,7 @@ void PnaclCoordinator::LoadCompiler() { ...@@ -385,7 +385,7 @@ void PnaclCoordinator::LoadCompiler() {
} }
void PnaclCoordinator::RunCompile(int32_t pp_error, void PnaclCoordinator::RunCompile(int32_t pp_error,
int64_t compiler_load_start_time) { base::TimeTicks compiler_load_start_time) {
PLUGIN_PRINTF( PLUGIN_PRINTF(
("PnaclCoordinator::RunCompile (pp_error=%" NACL_PRId32 ")\n", pp_error)); ("PnaclCoordinator::RunCompile (pp_error=%" NACL_PRId32 ")\n", pp_error));
if (pp_error != PP_OK) { if (pp_error != PP_OK) {
...@@ -395,7 +395,7 @@ void PnaclCoordinator::RunCompile(int32_t pp_error, ...@@ -395,7 +395,7 @@ void PnaclCoordinator::RunCompile(int32_t pp_error,
return; return;
} }
int64_t compiler_load_time_total = int64_t compiler_load_time_total =
NaClGetTimeOfDayMicroseconds() - compiler_load_start_time; (base::TimeTicks::Now() - compiler_load_start_time).InMicroseconds();
GetNaClInterface()->LogTranslateTime("NaCl.Perf.PNaClLoadTime.LoadCompiler", GetNaClInterface()->LogTranslateTime("NaCl.Perf.PNaClLoadTime.LoadCompiler",
compiler_load_time_total); compiler_load_time_total);
GetNaClInterface()->LogTranslateTime( GetNaClInterface()->LogTranslateTime(
...@@ -428,7 +428,7 @@ void PnaclCoordinator::LoadLinker(int32_t pp_error) { ...@@ -428,7 +428,7 @@ void PnaclCoordinator::LoadLinker(int32_t pp_error) {
return; return;
} }
ErrorInfo error_info; ErrorInfo error_info;
int64_t ld_load_start_time = NaClGetTimeOfDayMicroseconds(); base::TimeTicks ld_load_start_time = base::TimeTicks::Now();
pp::CompletionCallback load_finished = callback_factory_.NewCallback( pp::CompletionCallback load_finished = callback_factory_.NewCallback(
&PnaclCoordinator::RunLink, ld_load_start_time); &PnaclCoordinator::RunLink, ld_load_start_time);
// Transfer file_info ownership to the sel_ldr launcher. // Transfer file_info ownership to the sel_ldr launcher.
...@@ -437,7 +437,8 @@ void PnaclCoordinator::LoadLinker(int32_t pp_error) { ...@@ -437,7 +437,8 @@ void PnaclCoordinator::LoadLinker(int32_t pp_error) {
ld_file_info, &ld_subprocess_, load_finished); ld_file_info, &ld_subprocess_, load_finished);
} }
void PnaclCoordinator::RunLink(int32_t pp_error, int64_t ld_load_start_time) { void PnaclCoordinator::RunLink(int32_t pp_error,
base::TimeTicks ld_load_start_time) {
PLUGIN_PRINTF( PLUGIN_PRINTF(
("PnaclCoordinator::RunLink (pp_error=%" NACL_PRId32 ")\n", pp_error)); ("PnaclCoordinator::RunLink (pp_error=%" NACL_PRId32 ")\n", pp_error));
if (pp_error != PP_OK) { if (pp_error != PP_OK) {
...@@ -448,7 +449,7 @@ void PnaclCoordinator::RunLink(int32_t pp_error, int64_t ld_load_start_time) { ...@@ -448,7 +449,7 @@ void PnaclCoordinator::RunLink(int32_t pp_error, int64_t ld_load_start_time) {
} }
GetNaClInterface()->LogTranslateTime( GetNaClInterface()->LogTranslateTime(
"NaCl.Perf.PNaClLoadTime.LoadLinker", "NaCl.Perf.PNaClLoadTime.LoadLinker",
NaClGetTimeOfDayMicroseconds() - ld_load_start_time); (base::TimeTicks::Now() - ld_load_start_time).InMicroseconds());
translate_thread_->RunLink(); translate_thread_->RunLink();
} }
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include "base/files/file.h" #include "base/files/file.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/memory/scoped_ptr.h" #include "base/memory/scoped_ptr.h"
#include "base/time/time.h"
#include "components/nacl/renderer/plugin/nacl_subprocess.h" #include "components/nacl/renderer/plugin/nacl_subprocess.h"
#include "components/nacl/renderer/plugin/plugin_error.h" #include "components/nacl/renderer/plugin/plugin_error.h"
#include "components/nacl/renderer/plugin/pnacl_resources.h" #include "components/nacl/renderer/plugin/pnacl_resources.h"
...@@ -103,9 +104,9 @@ class PnaclCoordinator { ...@@ -103,9 +104,9 @@ class PnaclCoordinator {
// been created, this starts the translation. Translation starts two // been created, this starts the translation. Translation starts two
// subprocesses, one for llc and one for ld. // subprocesses, one for llc and one for ld.
void LoadCompiler(); void LoadCompiler();
void RunCompile(int32_t pp_error, int64_t compile_load_start_time); void RunCompile(int32_t pp_error, base::TimeTicks compile_load_start_time);
void LoadLinker(int32_t pp_error); void LoadLinker(int32_t pp_error);
void RunLink(int32_t pp_error, int64_t ld_load_start_time); void RunLink(int32_t pp_error, base::TimeTicks ld_load_start_time);
// Invoked when translation is finished. // Invoked when translation is finished.
void TranslateFinished(int32_t pp_error); void TranslateFinished(int32_t pp_error);
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include <sstream> #include <sstream>
#include "base/logging.h" #include "base/logging.h"
#include "base/time/time.h"
#include "components/nacl/renderer/plugin/plugin.h" #include "components/nacl/renderer/plugin/plugin.h"
#include "components/nacl/renderer/plugin/plugin_error.h" #include "components/nacl/renderer/plugin/plugin_error.h"
#include "components/nacl/renderer/plugin/utility.h" #include "components/nacl/renderer/plugin/utility.h"
...@@ -214,7 +215,7 @@ void PnaclTranslateThread::DoCompile() { ...@@ -214,7 +215,7 @@ void PnaclTranslateThread::DoCompile() {
PLUGIN_PRINTF(("DoCompile using subzero: %d\n", pnacl_options_->use_subzero)); PLUGIN_PRINTF(("DoCompile using subzero: %d\n", pnacl_options_->use_subzero));
pp::Core* core = pp::Module::Get()->core(); pp::Core* core = pp::Module::Get()->core();
int64_t do_compile_start_time = NaClGetTimeOfDayMicroseconds(); base::TimeTicks do_compile_start_time = base::TimeTicks::Now();
std::vector<std::string> args; std::vector<std::string> args;
if (pnacl_options_->use_subzero) { if (pnacl_options_->use_subzero) {
...@@ -300,7 +301,8 @@ void PnaclTranslateThread::DoCompile() { ...@@ -300,7 +301,8 @@ void PnaclTranslateThread::DoCompile() {
TranslateFailed(PP_NACL_ERROR_PNACL_LLC_INTERNAL, error_str); TranslateFailed(PP_NACL_ERROR_PNACL_LLC_INTERNAL, error_str);
return; return;
} }
compile_time_ = NaClGetTimeOfDayMicroseconds() - do_compile_start_time; compile_time_ =
(base::TimeTicks::Now() - do_compile_start_time).InMicroseconds();
GetNaClInterface()->LogTranslateTime("NaCl.Perf.PNaClLoadTime.CompileTime", GetNaClInterface()->LogTranslateTime("NaCl.Perf.PNaClLoadTime.CompileTime",
compile_time_); compile_time_);
GetNaClInterface()->LogTranslateTime( GetNaClInterface()->LogTranslateTime(
...@@ -353,7 +355,7 @@ void PnaclTranslateThread::DoLink() { ...@@ -353,7 +355,7 @@ void PnaclTranslateThread::DoLink() {
ld_channel_peer_pid_)); ld_channel_peer_pid_));
} }
int64_t link_start_time = NaClGetTimeOfDayMicroseconds(); base::TimeTicks link_start_time = base::TimeTicks::Now();
bool success = false; bool success = false;
bool sent = ld_channel_filter_->Send( bool sent = ld_channel_filter_->Send(
new PpapiMsg_PnaclTranslatorLink(ld_input_files, nexe_file, &success)); new PpapiMsg_PnaclTranslatorLink(ld_input_files, nexe_file, &success));
...@@ -370,7 +372,7 @@ void PnaclTranslateThread::DoLink() { ...@@ -370,7 +372,7 @@ void PnaclTranslateThread::DoLink() {
GetNaClInterface()->LogTranslateTime( GetNaClInterface()->LogTranslateTime(
"NaCl.Perf.PNaClLoadTime.LinkTime", "NaCl.Perf.PNaClLoadTime.LinkTime",
NaClGetTimeOfDayMicroseconds() - link_start_time); (base::TimeTicks::Now() - link_start_time).InMicroseconds());
PLUGIN_PRINTF(("PnaclCoordinator: link (translator=%p) succeeded\n", PLUGIN_PRINTF(("PnaclCoordinator: link (translator=%p) succeeded\n",
this)); this));
......
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