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

Side by Side Diff: third_party/WebKit/Source/web/ImageDecodeBench.cpp

Issue 1879133002: Make ImageDecodeBench build once again (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove TestingPlatformSupport changes, no longer needed Created 4 years, 7 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 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 // Provides a minimal wrapping of the Blink image decoders. Used to perform 5 // Provides a minimal wrapping of the Blink image decoders. Used to perform
6 // a non-threaded, memory-to-memory image decode using micro second accuracy 6 // a non-threaded, memory-to-memory image decode using micro second accuracy
7 // clocks to measure image decode time. Optionally applies color correction 7 // clocks to measure image decode time. Optionally applies color correction
8 // during image decoding on supported platforms (default off). Usage: 8 // during image decoding on supported platforms (default off). Usage:
9 // 9 //
10 // % ninja -C /out/Release image_decode_bench && 10 // % ninja -C /out/Release image_decode_bench &&
11 // ./out/Release/image_decode_bench file [iterations] 11 // ./out/Release/image_decode_bench file [iterations]
12 // 12 //
13 // TODO(noel): Consider adding md5 checksum support to WTF. Use it to compute 13 // TODO(noel): Consider adding md5 checksum support to WTF. Use it to compute
14 // the decoded image frame md5 and output that value. 14 // the decoded image frame md5 and output that value.
15 // 15 //
16 // TODO(noel): Consider integrating this tool in Chrome telemetry for realz, 16 // TODO(noel): Consider integrating this tool in Chrome telemetry for realz,
17 // using the image corpii used to assess Blink image decode performance. Refer 17 // using the image corpii used to assess Blink image decode performance. Refer
18 // to http://crbug.com/398235#c103 and http://crbug.com/258324#c5 18 // to http://crbug.com/398235#c103 and http://crbug.com/258324#c5
19 19
20 #include "base/command_line.h"
20 #include "platform/SharedBuffer.h" 21 #include "platform/SharedBuffer.h"
21 #include "platform/image-decoders/ImageDecoder.h" 22 #include "platform/image-decoders/ImageDecoder.h"
22 #include "platform/testing/TestingPlatformSupport.h"
23 #include "public/platform/Platform.h" 23 #include "public/platform/Platform.h"
24 #include "public/web/WebKit.h" 24 #include "public/web/WebKit.h"
25 #include "wtf/OwnPtr.h" 25 #include "wtf/OwnPtr.h"
26 #include "wtf/PassRefPtr.h" 26 #include "wtf/PassRefPtr.h"
27 27
28 #if defined(_WIN32) 28 #if defined(_WIN32)
29 #if defined(WIN32_LEAN_AND_MEAN)
30 #error Fix: WIN32_LEAN_AND_MEAN disables timeBeginPeriod/TimeEndPeriod.
31 #endif
Noel Gordon 2016/05/02 12:34:55 Yeap, that looks good.
32 #include <mmsystem.h> 29 #include <mmsystem.h>
33 #include <sys/stat.h> 30 #include <sys/stat.h>
34 #include <time.h> 31 #include <time.h>
35 #define stat(x,y) _stat(x,y) 32 #define stat(x,y) _stat(x,y)
36 typedef struct _stat sttype; 33 typedef struct _stat sttype;
37 #else 34 #else
38 #include <sys/stat.h> 35 #include <sys/stat.h>
39 #include <sys/time.h> 36 #include <sys/time.h>
40 typedef struct stat sttype; 37 typedef struct stat sttype;
41 #endif 38 #endif
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 int frameCount = decoder->frameCount(); 270 int frameCount = decoder->frameCount();
274 for (int i = 0; i < frameCount; ++i) { 271 for (int i = 0; i < frameCount; ++i) {
275 if (!decoder->frameBufferAtIndex(i)) 272 if (!decoder->frameBufferAtIndex(i))
276 return false; 273 return false;
277 } 274 }
278 275
279 return !decoder->failed(); 276 return !decoder->failed();
280 } 277 }
281 278
282 RefPtr<SharedBuffer> packetData = SharedBuffer::create(); 279 RefPtr<SharedBuffer> packetData = SharedBuffer::create();
283 unsigned position = 0; 280 size_t position = 0;
284 while (true) { 281 while (true) {
285 const char* packet; 282 const char* packet;
286 unsigned length = data->getSomeData(packet, position); 283 size_t length = data->getSomeData(packet, position);
287 284
288 length = std::min(static_cast<size_t>(length), packetSize); 285 length = std::min(static_cast<size_t>(length), packetSize);
Noel Gordon 2016/05/02 12:34:55 nit: static_cast<size_t>(length) -> length
289 packetData->append(packet, length); 286 packetData->append(packet, length);
290 position += length; 287 position += length;
291 288
292 bool allDataReceived = position == data->size(); 289 bool allDataReceived = position == data->size();
293 decoder->setData(packetData.get(), allDataReceived); 290 decoder->setData(packetData.get(), allDataReceived);
294 291
295 int frameCount = decoder->frameCount(); 292 int frameCount = decoder->frameCount();
296 for (int i = 0; i < frameCount; ++i) { 293 for (int i = 0; i < frameCount; ++i) {
297 if (!decoder->frameBufferAtIndex(i)) 294 if (!decoder->frameBufferAtIndex(i))
298 break; 295 break;
299 } 296 }
300 297
301 if (allDataReceived || decoder->failed()) 298 if (allDataReceived || decoder->failed())
302 break; 299 break;
303 } 300 }
304 301
305 return !decoder->failed(); 302 return !decoder->failed();
306 } 303 }
307 304
308 int main(int argc, char* argv[]) 305 int main(int argc, char* argv[])
309 { 306 {
307 base::CommandLine::Init(argc, argv);
Noel Gordon 2016/05/02 12:34:55 As you noted, this is the thing we need to fix (du
310 char* name = argv[0]; 308 char* name = argv[0];
311 309
312 // If the platform supports color correction, allow it to be controlled. 310 // If the platform supports color correction, allow it to be controlled.
313 311
314 bool applyColorCorrection = false; 312 bool applyColorCorrection = false;
315 313
316 #if USE(QCMSLIB) 314 #if USE(QCMSLIB)
317 if (argc >= 2 && strcmp(argv[1], "--color-correct") == 0) 315 if (argc >= 2 && strcmp(argv[1], "--color-correct") == 0)
318 applyColorCorrection = (--argc, ++argv, true); 316 applyColorCorrection = (--argc, ++argv, true);
319 317
(...skipping 28 matching lines...) Expand all
348 if (*end != '\0') { 346 if (*end != '\0') {
349 fprintf(stderr, "Third argument should be packet size. Default is " 347 fprintf(stderr, "Third argument should be packet size. Default is "
350 "0, meaning to decode the entire image in one packet. You " 348 "0, meaning to decode the entire image in one packet. You "
351 "supplied %s\n", argv[3]); 349 "supplied %s\n", argv[3]);
352 exit(1); 350 exit(1);
353 } 351 }
354 } 352 }
355 353
356 // Create a web platform without V8. 354 // Create a web platform without V8.
357 355
358 class WebPlatform : public TestingPlatformSupport { 356 class WebPlatform : public blink::Platform {
359 public: 357 public:
360 void screenColorProfile(WebVector<char>* profile) override 358 void screenColorProfile(WebVector<char>* profile) override
361 { 359 {
362 getScreenColorProfile(profile); // Returns a whacked color profile. 360 getScreenColorProfile(profile); // Returns a whacked color profile.
363 } 361 }
364 }; 362 };
365 363
366 Platform::initialize(new WebPlatform()); 364 Platform::initialize(new WebPlatform());
367 365
368 // Set image decoding Platform options. 366 // Set image decoding Platform options.
369 367
370 #if USE(QCMSLIB)
371 ImageDecoder::qcmsOutputDeviceProfile(); // Initialize screen colorProfile.
372 #endif
373
374 // Read entire file content to data. 368 // Read entire file content to data.
375 369
376 RefPtr<SharedBuffer> data = readFile(argv[1]); 370 RefPtr<SharedBuffer> data = readFile(argv[1]);
377 if (!data.get() || !data->size()) { 371 if (!data.get() || !data->size()) {
378 fprintf(stderr, "Error reading image data from [%s]\n", argv[1]); 372 fprintf(stderr, "Error reading image data from [%s]\n", argv[1]);
379 exit(2); 373 exit(2);
380 } 374 }
381 375
382 // Consolidate the SharedBuffer data segments into one, contiguous block of memory. 376 // Consolidate the SharedBuffer data segments into one, contiguous block of memory.
383 data->data(); 377 data->data();
384 378
379 // Throw out the first iteration for more consistent data.
380 if (!decodeImageData(data.get(), applyColorCorrection, packetSize)) {
381 fprintf(stderr, "Image decode failed [%s]\n", argv[1]);
382 exit(3);
383 }
384
385 // Image decode bench for iterations. 385 // Image decode bench for iterations.
386 386
387 double totalTime = 0.0; 387 double totalTime = 0.0;
388 388
389 for (size_t i = 0; i < iterations; ++i) { 389 for (size_t i = 0; i < iterations; ++i) {
390 double startTime = getCurrentTime(); 390 double startTime = getCurrentTime();
391 bool decoded = decodeImageData(data.get(), applyColorCorrection, packetS ize); 391 bool decoded = decodeImageData(data.get(), applyColorCorrection, packetS ize);
392 double elapsedTime = getCurrentTime() - startTime; 392 double elapsedTime = getCurrentTime() - startTime;
393 totalTime += elapsedTime; 393 totalTime += elapsedTime;
394 if (!decoded) { 394 if (!decoded) {
395 fprintf(stderr, "Image decode failed [%s]\n", argv[1]); 395 fprintf(stderr, "Image decode failed [%s]\n", argv[1]);
396 exit(3); 396 exit(3);
397 } 397 }
398 } 398 }
399 399
400 // Results to stdout. 400 // Results to stdout.
401 401
402 double averageTime = totalTime / static_cast<double>(iterations); 402 double averageTime = totalTime / static_cast<double>(iterations);
403 printf("%f %f\n", totalTime, averageTime); 403 printf("%f %f\n", totalTime, averageTime);
404 return 0; 404 return 0;
405 } 405 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698