summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjar@chromium.org <jar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-07-30 18:41:53 +0000
committerjar@chromium.org <jar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-07-30 18:41:53 +0000
commit9e9999d8f45d81bb0520de7cf8a77574fe60a640 (patch)
tree6a5fd2d6ae2da77dc260609f10ad354567991ae4
parentda4ce91a27f49bd871ac0175f864a24b3273f9c2 (diff)
downloadchromium_src-9e9999d8f45d81bb0520de7cf8a77574fe60a640.zip
chromium_src-9e9999d8f45d81bb0520de7cf8a77574fe60a640.tar.gz
chromium_src-9e9999d8f45d81bb0520de7cf8a77574fe60a640.tar.bz2
Support profiling of tasks run as sequenced_tasks
Mimic code seen in message_loop.cc (since these tasks are run on named threads) to support tracking of sequenced worker pool runs of tasks. We surround the *.Run() method with a call to get the time before we start, and then call to tally the time it took to run after task.Run() returns. r=brettw BUG=139035 Review URL: https://chromiumcodereview.appspot.com/10825022 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@148986 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--base/threading/sequenced_worker_pool.cc19
-rw-r--r--base/tracking_info.cc7
-rw-r--r--base/tracking_info.h3
3 files changed, 23 insertions, 6 deletions
diff --git a/base/threading/sequenced_worker_pool.cc b/base/threading/sequenced_worker_pool.cc
index a1f7224..fb6b247 100644
--- a/base/threading/sequenced_worker_pool.cc
+++ b/base/threading/sequenced_worker_pool.cc
@@ -35,16 +35,21 @@ namespace base {
namespace {
-struct SequencedTask {
+struct SequencedTask : public TrackingInfo {
SequencedTask()
: sequence_token_id(0),
shutdown_behavior(SequencedWorkerPool::BLOCK_SHUTDOWN) {}
+ explicit SequencedTask(const tracked_objects::Location& from_here)
+ : base::TrackingInfo(from_here, TimeTicks()),
+ sequence_token_id(0),
+ shutdown_behavior(SequencedWorkerPool::BLOCK_SHUTDOWN) {}
+
~SequencedTask() {}
int sequence_token_id;
SequencedWorkerPool::WorkerShutdown shutdown_behavior;
- tracked_objects::Location location;
+ tracked_objects::Location posted_from;
Closure task;
};
@@ -481,10 +486,10 @@ bool SequencedWorkerPool::Inner::PostTask(
WorkerShutdown shutdown_behavior,
const tracked_objects::Location& from_here,
const Closure& task) {
- SequencedTask sequenced;
+ SequencedTask sequenced(from_here);
sequenced.sequence_token_id = sequence_token.id_;
sequenced.shutdown_behavior = shutdown_behavior;
- sequenced.location = from_here;
+ sequenced.posted_from = from_here;
sequenced.task = task;
int create_thread_id = 0;
@@ -614,8 +619,14 @@ void SequencedWorkerPool::Inner::ThreadLoop(Worker* this_worker) {
this_worker->set_running_sequence(
SequenceToken(task.sequence_token_id));
+ tracked_objects::TrackedTime start_time =
+ tracked_objects::ThreadData::NowForStartOfRun(task.birth_tally);
+
task.task.Run();
+ tracked_objects::ThreadData::TallyRunOnNamedThreadIfTracking(task,
+ start_time, tracked_objects::ThreadData::NowForEndOfRun());
+
this_worker->set_running_sequence(SequenceToken());
// Make sure our task is erased outside the lock for the same reason
diff --git a/base/tracking_info.cc b/base/tracking_info.cc
index 7ac4221..0b091f8 100644
--- a/base/tracking_info.cc
+++ b/base/tracking_info.cc
@@ -1,13 +1,18 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// 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/tracking_info.h"
+#include <stddef.h>
#include "base/tracked_objects.h"
namespace base {
+TrackingInfo::TrackingInfo()
+ : birth_tally(NULL) {
+}
+
TrackingInfo::TrackingInfo(
const tracked_objects::Location& posted_from,
base::TimeTicks delayed_run_time)
diff --git a/base/tracking_info.h b/base/tracking_info.h
index 0886fdf..738bdee 100644
--- a/base/tracking_info.h
+++ b/base/tracking_info.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// 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.
@@ -22,6 +22,7 @@ namespace base {
// This structure is copied around by value.
struct BASE_EXPORT TrackingInfo {
+ TrackingInfo();
TrackingInfo(const tracked_objects::Location& posted_from,
base::TimeTicks delayed_run_time);
~TrackingInfo();