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

Unified Diff: apps/benchmark/measurements.h

Issue 1305193002: Trace-based benchmarking via a mojo app. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Further address Etienne's comments. Created 5 years, 4 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 | « apps/benchmark/event_unittest.cc ('k') | apps/benchmark/measurements.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: apps/benchmark/measurements.h
diff --git a/apps/benchmark/measurements.h b/apps/benchmark/measurements.h
new file mode 100644
index 0000000000000000000000000000000000000000..eeb472795e39236664c41acc56a5d7e643184339
--- /dev/null
+++ b/apps/benchmark/measurements.h
@@ -0,0 +1,65 @@
+// Copyright 2015 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.
+
+#ifndef APPS_BENCHMARK_MEASUREMENTS_HH_
+#define APPS_BENCHMARK_MEASUREMENTS_HH_
+
+#include <vector>
+
+#include "apps/benchmark/event.h"
+#include "base/macros.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/time/time.h"
+#include "base/values.h"
+
+namespace benchmark {
+
+// Describes a trace event to match.
+struct EventSpec {
+ std::string name;
+ std::string category;
+
+ EventSpec();
+ EventSpec(std::string name, std::string category);
+ ~EventSpec();
+};
+
+enum class MeasurementType { TIME_UNTIL, AVG_DURATION };
+
+// Represents a single measurement to be performed on the collected trace.
+struct Measurement {
+ MeasurementType type;
+ EventSpec target_event;
+ // Optional string from which this measurement was parsed. Can be used for
+ // presentation purposes.
+ std::string spec;
+
+ Measurement();
+ Measurement(MeasurementType type,
+ std::string target_name,
+ std::string target_category);
+ ~Measurement();
+};
+
+class Measurements {
+ public:
+ Measurements(std::vector<Event> events, base::TimeTicks time_origin);
+ ~Measurements();
+
+ // Performs the given measurement. Returns the result in milliseconds or -1.0
+ // if the measurement failed, e.g. because no events were matched.
+ double Measure(const Measurement& measurement);
+
+ private:
+ double TimeUntil(const EventSpec& event_spec);
+ double AvgDuration(const EventSpec& event_spec);
+
+ std::vector<Event> events_;
+ base::TimeTicks time_origin_;
+ DISALLOW_COPY_AND_ASSIGN(Measurements);
+};
+
+} // namespace benchmark
+
+#endif // APPS_BENCHMARK_MEASUREMENTS_HH_
« no previous file with comments | « apps/benchmark/event_unittest.cc ('k') | apps/benchmark/measurements.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698