1 /* Copyright 2017 The TensorFlow Authors. All Rights Reserved.
2 
3 Licensed under the Apache License, Version 2.0 (the "License");
4 you may not use this file except in compliance with the License.
5 You may obtain a copy of the License at
6 
7     http://www.apache.org/licenses/LICENSE-2.0
8 
9 Unless required by applicable law or agreed to in writing, software
10 distributed under the License is distributed on an "AS IS" BASIS,
11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 See the License for the specific language governing permissions and
13 limitations under the License.
14 ==============================================================================*/
15 
16 #include "tensorflow/compiler/aot/benchmark.h"
17 
18 #include "tensorflow/compiler/aot/test_graph_tfadd.h"
19 #include "tensorflow/core/platform/test.h"
20 
21 namespace tensorflow {
22 namespace tfcompile {
23 namespace benchmark {
24 namespace {
25 
26 // There isn't much we can verify in a stable fashion, so we just run the
27 // benchmark with max_iters, and ensure we end up with that many iter stats.
TEST(Benchmark,Benchmark)28 TEST(Benchmark, Benchmark) {
29   AddComp add;
30 
31   Options options;
32   options.max_iters = 1;
33   Stats stats1;
34   Benchmark(options, [&] { add.Run(); }, &stats1);
35   EXPECT_EQ(stats1.per_iter_us.size(), 1);
36 
37   options.max_iters = 5;
38   Stats stats5;
39   Benchmark(options, [&] { add.Run(); }, &stats5);
40   EXPECT_EQ(stats5.per_iter_us.size(), 5);
41 }
42 
43 }  // namespace
44 }  // namespace benchmark
45 }  // namespace tfcompile
46 }  // namespace tensorflow
47