1 // Copyright 2017 The Fuchsia 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 #include "benchmarks.h"
6 
7 #include "runner.h"
8 
9 namespace {
10 
11 // Trace buffer sizes.
12 // "large" must be sized so it does not overflow during oneshot tests.
13 // The benchmark will assert-fail if the buffer fills: Otherwise the benchmark
14 // is invalid.
15 static constexpr size_t kLargeBufferSizeBytes = 16 * 1024 * 1024;
16 // "small" is sized so the buffer does fill, repeatedly, during the test.
17 // The number is chosen to make it easier to eyeball timing differences
18 // between large and small.
19 static constexpr size_t kSmallBufferSizeBytes = 16 * 1024;
20 
21 } // namespace
22 
main(int argc,char ** argv)23 int main(int argc, char** argv) {
24     RunTracingDisabledBenchmarks();
25     RunNoTraceBenchmarks();
26 
27     static const BenchmarkSpec specs[] = {
28         {
29             // Note: The buffer is not allowed to fill in oneshot mode.
30             "oneshot, 16MB buffer",
31             TRACE_BUFFERING_MODE_ONESHOT,
32             kLargeBufferSizeBytes,
33             kDefaultRunIterations,
34         },
35         {
36             "streaming, 16MB buffer",
37             TRACE_BUFFERING_MODE_STREAMING,
38             kLargeBufferSizeBytes,
39             kDefaultRunIterations,
40         },
41         {
42             "circular, 16MB buffer",
43             TRACE_BUFFERING_MODE_CIRCULAR,
44             kLargeBufferSizeBytes,
45             kDefaultRunIterations,
46         },
47         {
48             "streaming, 16K buffer",
49             TRACE_BUFFERING_MODE_STREAMING,
50             kSmallBufferSizeBytes,
51             kDefaultRunIterations,
52         },
53         {
54             "circular, 16K buffer",
55             TRACE_BUFFERING_MODE_CIRCULAR,
56             kSmallBufferSizeBytes,
57             kDefaultRunIterations,
58         },
59     };
60 
61     for (const auto& spec : specs) {
62         RunTracingEnabledBenchmarks(&spec);
63     }
64 
65     printf("\nTracing benchmarks completed.\n");
66     return 0;
67 }
68