| OLD | NEW |
| 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 #ifdef WTF | 5 #ifdef WTF |
| 6 | 6 |
| 7 Provides a minimal wrapping of the Blink image decoders. Used to perform | 7 Provides a minimal wrapping of the Blink image decoders. Used to perform |
| 8 a non-threaded, memory-to-memory image decode using micro second accuracy | 8 a non-threaded, memory-to-memory image decode using micro second accuracy |
| 9 clocks to measure image decode time. Optionally applies color correction | 9 clocks to measure image decode time. Optionally applies color correction |
| 10 during image decoding on supported platforms (default off). Usage: | 10 during image decoding on supported platforms (default off). Usage: |
| 11 | 11 |
| 12 % ninja -C /out/Release image_decode_bench && | 12 % ninja -C /out/Release image_decode_bench && |
| 13 ./out/Release/image_decode_bench file [iterations] | 13 ./out/Release/image_decode_bench file [iterations] |
| 14 | 14 |
| 15 FIXME: Consider adding md5 checksum support to WTF. Use it to compute the | 15 FIXME: Consider adding md5 checksum support to WTF. Use it to compute the |
| 16 decoded image frame md5 and output that value. | 16 decoded image frame md5 and output that value. |
| 17 | 17 |
| 18 FIXME: Consider integrating this tool in Chrome telemetry for realz, using | 18 FIXME: Consider integrating this tool in Chrome telemetry for realz, using |
| 19 the image corpii used to assess Blink image decode performance. Refer to | 19 the image corpii used to assess Blink image decode performance. Refer to |
| 20 http://crbug.com/398235#c103 and http://crbug.com/258324#c5 | 20 http://crbug.com/398235#c103 and http://crbug.com/258324#c5 |
| 21 | 21 |
| 22 #endif | 22 #endif |
| 23 | 23 |
| 24 #include "platform/SharedBuffer.h" | 24 #include "platform/SharedBuffer.h" |
| 25 #include "platform/image-decoders/ImageDecoder.h" | 25 #include "platform/image-decoders/ImageDecoder.h" |
| 26 #include "platform/image-decoders/SharedBufferSegmentReader.h" |
| 26 #include "platform/testing/TestingPlatformSupport.h" | 27 #include "platform/testing/TestingPlatformSupport.h" |
| 27 #include "public/platform/Platform.h" | 28 #include "public/platform/Platform.h" |
| 28 #include "public/web/WebKit.h" | 29 #include "public/web/WebKit.h" |
| 29 #include "wtf/OwnPtr.h" | 30 #include "wtf/OwnPtr.h" |
| 30 #include "wtf/PassRefPtr.h" | 31 #include "wtf/PassRefPtr.h" |
| 31 | 32 |
| 32 #if defined(_WIN32) | 33 #if defined(_WIN32) |
| 33 #if defined(WIN32_LEAN_AND_MEAN) | 34 #if defined(WIN32_LEAN_AND_MEAN) |
| 34 #error Fix: WIN32_LEAN_AND_MEAN disables timeBeginPeriod/TimeEndPeriod. | 35 #error Fix: WIN32_LEAN_AND_MEAN disables timeBeginPeriod/TimeEndPeriod. |
| 35 #endif | 36 #endif |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 unsigned position = 0; | 288 unsigned position = 0; |
| 288 while (true) { | 289 while (true) { |
| 289 const char* packet; | 290 const char* packet; |
| 290 unsigned length = data->getSomeData(packet, position); | 291 unsigned length = data->getSomeData(packet, position); |
| 291 | 292 |
| 292 length = std::min(static_cast<size_t>(length), packetSize); | 293 length = std::min(static_cast<size_t>(length), packetSize); |
| 293 packetData->append(packet, length); | 294 packetData->append(packet, length); |
| 294 position += length; | 295 position += length; |
| 295 | 296 |
| 296 bool allDataReceived = position == data->size(); | 297 bool allDataReceived = position == data->size(); |
| 297 decoder->setData(packetData.get(), allDataReceived); | 298 decoder->setData(packetData, allDataReceived); |
| 298 | 299 |
| 299 int frameCount = decoder->frameCount(); | 300 int frameCount = decoder->frameCount(); |
| 300 for (int i = 0; i < frameCount; ++i) { | 301 for (int i = 0; i < frameCount; ++i) { |
| 301 if (!decoder->frameBufferAtIndex(i)) | 302 if (!decoder->frameBufferAtIndex(i)) |
| 302 break; | 303 break; |
| 303 } | 304 } |
| 304 | 305 |
| 305 if (allDataReceived || decoder->failed()) | 306 if (allDataReceived || decoder->failed()) |
| 306 break; | 307 break; |
| 307 } | 308 } |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 400 exit(3); | 401 exit(3); |
| 401 } | 402 } |
| 402 } | 403 } |
| 403 | 404 |
| 404 // Results to stdout. | 405 // Results to stdout. |
| 405 | 406 |
| 406 double averageTime = totalTime / static_cast<double>(iterations); | 407 double averageTime = totalTime / static_cast<double>(iterations); |
| 407 printf("%f %f\n", totalTime, averageTime); | 408 printf("%f %f\n", totalTime, averageTime); |
| 408 return 0; | 409 return 0; |
| 409 } | 410 } |
| OLD | NEW |