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

Side by Side 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, 3 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 unified diff | Download patch
« no previous file with comments | « apps/benchmark/event_unittest.cc ('k') | apps/benchmark/measurements.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef APPS_BENCHMARK_MEASUREMENTS_HH_
6 #define APPS_BENCHMARK_MEASUREMENTS_HH_
7
8 #include <vector>
9
10 #include "apps/benchmark/event.h"
11 #include "base/macros.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "base/time/time.h"
14 #include "base/values.h"
15
16 namespace benchmark {
17
18 // Describes a trace event to match.
19 struct EventSpec {
20 std::string name;
21 std::string category;
22
23 EventSpec();
24 EventSpec(std::string name, std::string category);
25 ~EventSpec();
26 };
27
28 enum class MeasurementType { TIME_UNTIL, AVG_DURATION };
29
30 // Represents a single measurement to be performed on the collected trace.
31 struct Measurement {
32 MeasurementType type;
33 EventSpec target_event;
34 // Optional string from which this measurement was parsed. Can be used for
35 // presentation purposes.
36 std::string spec;
37
38 Measurement();
39 Measurement(MeasurementType type,
40 std::string target_name,
41 std::string target_category);
42 ~Measurement();
43 };
44
45 class Measurements {
46 public:
47 Measurements(std::vector<Event> events, base::TimeTicks time_origin);
48 ~Measurements();
49
50 // Performs the given measurement. Returns the result in milliseconds or -1.0
51 // if the measurement failed, e.g. because no events were matched.
52 double Measure(const Measurement& measurement);
53
54 private:
55 double TimeUntil(const EventSpec& event_spec);
56 double AvgDuration(const EventSpec& event_spec);
57
58 std::vector<Event> events_;
59 base::TimeTicks time_origin_;
60 DISALLOW_COPY_AND_ASSIGN(Measurements);
61 };
62
63 } // namespace benchmark
64
65 #endif // APPS_BENCHMARK_MEASUREMENTS_HH_
OLDNEW
« 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