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

Unified Diff: components/tracing/test/trace_event_perftest.cc

Issue 2450953003: Tracing macros perftests. (Closed)
Patch Set: Created 4 years, 2 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/tracing/test/trace_event_perftest.cc
diff --git a/components/tracing/test/trace_event_perftest.cc b/components/tracing/test/trace_event_perftest.cc
index 4c93e2fb0cfefbc34bf495d40036bebe2543f0f2..98f398a1424794b905f4b4dbcfe3ef44af3712e9 100644
--- a/components/tracing/test/trace_event_perftest.cc
+++ b/components/tracing/test/trace_event_perftest.cc
@@ -3,9 +3,11 @@
// found in the LICENSE file.
#include "base/bind.h"
+#include "base/memory/ptr_util.h"
#include "base/memory/ref_counted_memory.h"
#include "base/run_loop.h"
#include "base/trace_event/trace_event.h"
+#include "base/trace_event/trace_event_argument.h"
#include "perf_test_helpers.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -15,6 +17,7 @@ namespace {
using base::trace_event::TraceConfig;
using base::trace_event::TraceLog;
using base::trace_event::TraceRecordMode;
+using base::trace_event::TracedValue;
const int kNumRuns = 100;
@@ -35,6 +38,24 @@ class TraceEventPerfTest : public ::testing::Test {
run_loop.Run();
}
+ std::unique_ptr<TracedValue> MakeTracedValue(int counter) {
+ auto value = base::WrapUnique(new TracedValue);
Primiano Tucci (use gerrit) 2016/10/28 09:43:11 I think MakeUnique is the preferred one for new in
+ value->SetInteger("counter", counter);
+ value->BeginDictionary("test_dict");
+ value->BeginArray("nodes");
+ for (int i = 0; i < 10; i++) {
+ value->BeginDictionary();
+ value->SetInteger("id", i);
+ value->SetBoolean("valid", true);
+ value->SetString("value", "foo");
+ value->EndDictionary();
+ }
+ value->EndArray();
+ value->SetInteger("count", 10);
+ value->EndDictionary();
+ return value;
+ }
+
static void OnTraceDataCollected(
base::Closure quit_closure,
const scoped_refptr<base::RefCountedString>& events_str,
@@ -57,5 +78,39 @@ TEST_F(TraceEventPerfTest, Submit_10000_TRACE_EVENT0) {
EndTraceAndFlush();
}
+TEST_F(TraceEventPerfTest, Long_TRACE_EVENT0) {
+ BeginTrace();
+ IterableStopwatch stopwatch("long_event");
+ for (int lap = 0; lap < kNumRuns; lap++) {
+ TRACE_EVENT0("test_category", "Outter event");
Primiano Tucci (use gerrit) 2016/10/28 09:43:11 typo, extra t in outter
+ for (int i = 0; i < 10000; i++) {
+ TRACE_EVENT0("test_category", "TRACE_EVENT0 call");
+ }
+ stopwatch.NextLap();
+ }
+ EndTraceAndFlush();
+}
+
+TEST_F(TraceEventPerfTest, UsingTracedValue) {
+ BeginTrace();
+ std::unique_ptr<TracedValue> value;
+ {
+ ScopedStopwatch value_sw("create_traced_values");
+ for (int i = 0; i < 10000; i++) {
+ value = MakeTracedValue(i);
+ }
+ }
+
+ IterableStopwatch trace_sw("instant_events_with_value");
Primiano Tucci (use gerrit) 2016/10/28 09:43:11 i'd just drop instant_ here to keep the metric mor
+ for (int lap = 0; lap < kNumRuns; lap++) {
+ for (int i = 0; i < 10000; i++) {
+ TRACE_EVENT_INSTANT1("test_category", "event_with_value",
+ TRACE_EVENT_SCOPE_THREAD, "value", MakeTracedValue(i));
+ }
+ trace_sw.NextLap();
+ }
+ EndTraceAndFlush();
+}
+
} // namespace
} // namespace tracing
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698