MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / Run

Method Run

tensorflow/core/platform/default/test_benchmark.cc:113–204  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

111}
112
113void Benchmark::Run(const char* pattern) {
114 if (!all_benchmarks) return;
115
116 // Converts "all" into the wildcard '.*'. Currently pattern isn't
117 // specified by clients, but we keep this here to match the internal
118 // Google implementation, should we ever enable user-specified
119 // pattern specification.
120 if (StringPiece(pattern) == "all") {
121 pattern = ".*";
122 }
123
124 // Compute name width.
125 int width = 10;
126 string name;
127 for (auto b : *all_benchmarks) {
128 name = b->name_;
129 for (auto arg : b->args_) {
130 name.resize(b->name_.size());
131 if (arg.first >= 0) {
132 strings::StrAppend(&name, "/", arg.first);
133 if (arg.second >= 0) {
134 strings::StrAppend(&name, "/", arg.second);
135 }
136 }
137
138 // TODO(vrv): Check against 'pattern' using a regex before
139 // computing the width, if we start allowing clients to pass in
140 // a custom pattern.
141 width = std::max<int>(width, name.size());
142 }
143 }
144
145 printf("%-*s %10s %10s\n", width, "Benchmark", "Time(ns)", "Iterations");
146 printf("%s\n", string(width + 22, '-').c_str());
147 for (auto b : *all_benchmarks) {
148 name = b->name_;
149 for (auto arg : b->args_) {
150 name.resize(b->name_.size());
151 if (arg.first >= 0) {
152 strings::StrAppend(&name, "/", arg.first);
153 if (arg.second >= 0) {
154 strings::StrAppend(&name, "/", arg.second);
155 }
156 }
157
158 // TODO(vrv): Match 'name' against 'pattern' using a regex
159 // before continuing, if we start allowing clients to pass in a
160 // custom pattern.
161
162 int iters;
163 double seconds;
164 if (arg.second > 0) {
165 b->RunWithFixedIters(arg.first, arg.second, &iters, &seconds);
166 } else {
167 b->Run(arg.first, arg.second, &iters, &seconds);
168 }
169
170 char buf[100];

Callers 1

TEST_FFunction · 0.45

Calls 15

exitFunction · 0.85
DefaultFunction · 0.85
StopTimingFunction · 0.85
c_strMethod · 0.80
RunWithFixedItersMethod · 0.80
StrAppendFunction · 0.50
maxFunction · 0.50
minFunction · 0.50
resizeMethod · 0.45
sizeMethod · 0.45
InitializeMethod · 0.45
okMethod · 0.45

Tested by

no test coverage detected