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

Side by Side Diff: skia/ext/image_operations_bench.cc

Issue 1540963004: Switch to standard integer types in skia/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: missed some Created 5 years 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // This small program is used to measure the performance of the various 5 // This small program is used to measure the performance of the various
6 // resize algorithms offered by the ImageOperations::Resize function. 6 // resize algorithms offered by the ImageOperations::Resize function.
7 // It will generate an empty source bitmap, and rescale it to specified 7 // It will generate an empty source bitmap, and rescale it to specified
8 // dimensions. It will repeat this operation multiple time to get more accurate 8 // dimensions. It will repeat this operation multiple time to get more accurate
9 // average throughput. Because it uses elapsed time to do its math, it is only 9 // average throughput. Because it uses elapsed time to do its math, it is only
10 // accurate on an idle system (but that approach was deemed more accurate 10 // accurate on an idle system (but that approach was deemed more accurate
11 // than the use of the times() call. 11 // than the use of the times() call.
12 // To present a single number in MB/s, it calculates the 'speed' by taking 12 // To present a single number in MB/s, it calculates the 'speed' by taking
13 // source surface + destination surface and dividing by the elapsed time. 13 // source surface + destination surface and dividing by the elapsed time.
14 // This number is somewhat reasonable way to measure this, given our current 14 // This number is somewhat reasonable way to measure this, given our current
15 // implementation which somewhat scales this way. 15 // implementation which somewhat scales this way.
16 16
17 #include <stddef.h>
18 #include <stdint.h>
17 #include <stdio.h> 19 #include <stdio.h>
18 20
19 #include "base/basictypes.h"
20 #include "base/command_line.h" 21 #include "base/command_line.h"
21 #include "base/format_macros.h" 22 #include "base/format_macros.h"
23 #include "base/macros.h"
22 #include "base/strings/string_number_conversions.h" 24 #include "base/strings/string_number_conversions.h"
23 #include "base/strings/string_split.h" 25 #include "base/strings/string_split.h"
24 #include "base/strings/string_util.h" 26 #include "base/strings/string_util.h"
25 #include "base/strings/utf_string_conversions.h" 27 #include "base/strings/utf_string_conversions.h"
26 #include "base/time/time.h" 28 #include "base/time/time.h"
29 #include "build/build_config.h"
27 #include "skia/ext/image_operations.h" 30 #include "skia/ext/image_operations.h"
28 #include "third_party/skia/include/core/SkBitmap.h" 31 #include "third_party/skia/include/core/SkBitmap.h"
29 #include "third_party/skia/include/core/SkRect.h" 32 #include "third_party/skia/include/core/SkRect.h"
30 33
31 namespace { 34 namespace {
32 35
33 struct StringMethodPair { 36 struct StringMethodPair {
34 const char* name; 37 const char* name;
35 skia::ImageOperations::ResizeMethod method; 38 skia::ImageOperations::ResizeMethod method;
36 }; 39 };
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 SkBitmap dest; 236 SkBitmap dest;
234 237
235 const base::TimeTicks start = base::TimeTicks::Now(); 238 const base::TimeTicks start = base::TimeTicks::Now();
236 239
237 for (int i = 0; i < num_iterations_; ++i) { 240 for (int i = 0; i < num_iterations_; ++i) {
238 dest = skia::ImageOperations::Resize(source, 241 dest = skia::ImageOperations::Resize(source,
239 method_, 242 method_,
240 dest_.width(), dest_.height()); 243 dest_.width(), dest_.height());
241 } 244 }
242 245
243 const int64 elapsed_us = (base::TimeTicks::Now() - start).InMicroseconds(); 246 const int64_t elapsed_us = (base::TimeTicks::Now() - start).InMicroseconds();
244 247
245 const uint64 num_bytes = static_cast<uint64>(num_iterations_) * 248 const uint64_t num_bytes = static_cast<uint64_t>(num_iterations_) *
246 (GetBitmapSize(&source) + GetBitmapSize(&dest)); 249 (GetBitmapSize(&source) + GetBitmapSize(&dest));
247 250
248 printf("%" PRIu64 " MB/s,\telapsed = %" PRIu64 " source=%d dest=%d\n", 251 printf("%" PRIu64 " MB/s,\telapsed = %" PRIu64 " source=%d dest=%d\n",
249 static_cast<uint64>(elapsed_us == 0 ? 0 : num_bytes / elapsed_us), 252 static_cast<uint64_t>(elapsed_us == 0 ? 0 : num_bytes / elapsed_us),
250 static_cast<uint64>(elapsed_us), 253 static_cast<uint64_t>(elapsed_us), GetBitmapSize(&source),
251 GetBitmapSize(&source), GetBitmapSize(&dest)); 254 GetBitmapSize(&dest));
252 255
253 return true; 256 return true;
254 } 257 }
255 258
256 // A small class to automatically call Reset on the global command line to 259 // A small class to automatically call Reset on the global command line to
257 // avoid nasty valgrind complaints for the leak of the global command line. 260 // avoid nasty valgrind complaints for the leak of the global command line.
258 class CommandLineAutoReset { 261 class CommandLineAutoReset {
259 public: 262 public:
260 CommandLineAutoReset(int argc, char** argv) { 263 CommandLineAutoReset(int argc, char** argv) {
261 base::CommandLine::Init(argc, argv); 264 base::CommandLine::Init(argc, argv);
(...skipping 18 matching lines...) Expand all
280 return 1; 283 return 1;
281 } 284 }
282 285
283 if (!bench.Run()) { 286 if (!bench.Run()) {
284 printf("Failed to run benchmark\n"); 287 printf("Failed to run benchmark\n");
285 return 1; 288 return 1;
286 } 289 }
287 290
288 return 0; 291 return 0;
289 } 292 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698