| 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 // 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 "base/command_line.h" |
| 21 #include "platform/SharedBuffer.h" | 21 #include "platform/SharedBuffer.h" |
| 22 #include "platform/image-decoders/ImageDecoder.h" | 22 #include "platform/image-decoders/ImageDecoder.h" |
| 23 #include "public/platform/Platform.h" | 23 #include "public/platform/Platform.h" |
| 24 #include "ui/gfx/test/icc_profiles.h" |
| 24 #include "wtf/PassRefPtr.h" | 25 #include "wtf/PassRefPtr.h" |
| 25 #include "wtf/PtrUtil.h" | 26 #include "wtf/PtrUtil.h" |
| 26 #include <memory> | 27 #include <memory> |
| 27 | 28 |
| 28 #if defined(_WIN32) | 29 #if defined(_WIN32) |
| 29 #include <mmsystem.h> | 30 #include <mmsystem.h> |
| 30 #include <sys/stat.h> | 31 #include <sys/stat.h> |
| 31 #include <time.h> | 32 #include <time.h> |
| 32 #define stat(x, y) _stat(x, y) | 33 #define stat(x, y) _stat(x, y) |
| 33 typedef struct _stat sttype; | 34 typedef struct _stat sttype; |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 #else | 169 #else |
| 169 | 170 |
| 170 static double getCurrentTime() { | 171 static double getCurrentTime() { |
| 171 struct timeval now; | 172 struct timeval now; |
| 172 gettimeofday(&now, 0); | 173 gettimeofday(&now, 0); |
| 173 return now.tv_sec + now.tv_usec * (1.0 / 1000000.0); | 174 return now.tv_sec + now.tv_usec * (1.0 / 1000000.0); |
| 174 } | 175 } |
| 175 | 176 |
| 176 #endif | 177 #endif |
| 177 | 178 |
| 178 void getScreenColorProfile(WebVector<char>* profile) { | |
| 179 static unsigned char profileData[] = { | |
| 180 0x00, 0x00, 0x01, 0xea, 0x54, 0x45, 0x53, 0x54, 0x00, 0x00, 0x00, 0x00, | |
| 181 0x6d, 0x6e, 0x74, 0x72, 0x52, 0x47, 0x42, 0x20, 0x58, 0x59, 0x5a, 0x20, | |
| 182 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 183 0x61, 0x63, 0x73, 0x70, 0x74, 0x65, 0x73, 0x74, 0x00, 0x00, 0x00, 0x00, | |
| 184 0x74, 0x65, 0x73, 0x74, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 185 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf6, 0xd6, | |
| 186 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0xd3, 0x2d, 0x74, 0x65, 0x73, 0x74, | |
| 187 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 188 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 189 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 190 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, | |
| 191 0x63, 0x70, 0x72, 0x74, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x00, 0x00, 0x0d, | |
| 192 0x64, 0x65, 0x73, 0x63, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x8c, | |
| 193 0x77, 0x74, 0x70, 0x74, 0x00, 0x00, 0x01, 0x8c, 0x00, 0x00, 0x00, 0x14, | |
| 194 0x72, 0x58, 0x59, 0x5a, 0x00, 0x00, 0x01, 0xa0, 0x00, 0x00, 0x00, 0x14, | |
| 195 0x67, 0x58, 0x59, 0x5a, 0x00, 0x00, 0x01, 0xb4, 0x00, 0x00, 0x00, 0x14, | |
| 196 0x62, 0x58, 0x59, 0x5a, 0x00, 0x00, 0x01, 0xc8, 0x00, 0x00, 0x00, 0x14, | |
| 197 0x72, 0x54, 0x52, 0x43, 0x00, 0x00, 0x01, 0xdc, 0x00, 0x00, 0x00, 0x0e, | |
| 198 0x67, 0x54, 0x52, 0x43, 0x00, 0x00, 0x01, 0xdc, 0x00, 0x00, 0x00, 0x0e, | |
| 199 0x62, 0x54, 0x52, 0x43, 0x00, 0x00, 0x01, 0xdc, 0x00, 0x00, 0x00, 0x0e, | |
| 200 0x74, 0x65, 0x78, 0x74, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 201 0x00, 0x00, 0x00, 0x00, 0x64, 0x65, 0x73, 0x63, 0x00, 0x00, 0x00, 0x00, | |
| 202 0x00, 0x00, 0x00, 0x10, 0x77, 0x68, 0x61, 0x63, 0x6b, 0x65, 0x64, 0x2e, | |
| 203 0x69, 0x63, 0x63, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 204 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 205 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 206 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 207 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 208 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 209 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 210 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 211 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 212 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 213 0x58, 0x59, 0x5a, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf3, 0x52, | |
| 214 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x16, 0xcc, 0x58, 0x59, 0x5a, 0x20, | |
| 215 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x34, 0x8d, 0x00, 0x00, 0xa0, 0x2c, | |
| 216 0x00, 0x00, 0x0f, 0x95, 0x58, 0x59, 0x5a, 0x20, 0x00, 0x00, 0x00, 0x00, | |
| 217 0x00, 0x00, 0x26, 0x31, 0x00, 0x00, 0x10, 0x2f, 0x00, 0x00, 0xbe, 0x9b, | |
| 218 0x58, 0x59, 0x5a, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9c, 0x18, | |
| 219 0x00, 0x00, 0x4f, 0xa5, 0x00, 0x00, 0x04, 0xfc, 0x63, 0x75, 0x72, 0x76, | |
| 220 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x33}; | |
| 221 | |
| 222 static struct WhackedColorProfile { | |
| 223 char* data() { return reinterpret_cast<char*>(profileData); } | |
| 224 | |
| 225 const size_t profileSize = 490u; | |
| 226 | |
| 227 size_t size() { return profileSize; } | |
| 228 | |
| 229 } screenProfile; | |
| 230 | |
| 231 profile->assign(screenProfile.data(), screenProfile.size()); | |
| 232 } | |
| 233 | |
| 234 PassRefPtr<SharedBuffer> readFile(const char* fileName) { | 179 PassRefPtr<SharedBuffer> readFile(const char* fileName) { |
| 235 FILE* fp = fopen(fileName, "rb"); | 180 FILE* fp = fopen(fileName, "rb"); |
| 236 if (!fp) { | 181 if (!fp) { |
| 237 fprintf(stderr, "Can't open file %s\n", fileName); | 182 fprintf(stderr, "Can't open file %s\n", fileName); |
| 238 exit(2); | 183 exit(2); |
| 239 } | 184 } |
| 240 | 185 |
| 241 sttype s; | 186 sttype s; |
| 242 stat(fileName, &s); | 187 stat(fileName, &s); |
| 243 size_t fileSize = s.st_size; | 188 size_t fileSize = s.st_size; |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 303 | 248 |
| 304 int main(int argc, char* argv[]) { | 249 int main(int argc, char* argv[]) { |
| 305 base::CommandLine::Init(argc, argv); | 250 base::CommandLine::Init(argc, argv); |
| 306 | 251 |
| 307 // If the platform supports color correction, allow it to be controlled. | 252 // If the platform supports color correction, allow it to be controlled. |
| 308 | 253 |
| 309 bool applyColorCorrection = false; | 254 bool applyColorCorrection = false; |
| 310 | 255 |
| 311 if (argc >= 2 && strcmp(argv[1], "--color-correct") == 0) { | 256 if (argc >= 2 && strcmp(argv[1], "--color-correct") == 0) { |
| 312 applyColorCorrection = (--argc, ++argv, true); | 257 applyColorCorrection = (--argc, ++argv, true); |
| 313 WebVector<char> profile; | 258 gfx::ICCProfile iccProfile = gfx::ICCProfileForTestingColorSpin(); |
| 314 getScreenColorProfile(&profile); // Returns a color spin color profile. | 259 ColorBehavior::setGlobalTargetColorSpace( |
| 315 ColorBehavior::setGlobalTargetColorProfile(profile); | 260 iccProfile.GetColorSpace().ToSkColorSpace()); |
| 316 } | 261 } |
| 317 | 262 |
| 318 if (argc < 2) { | 263 if (argc < 2) { |
| 319 fprintf(stderr, | 264 fprintf(stderr, |
| 320 "Usage: %s [--color-correct] file [iterations] [packetSize]\n", | 265 "Usage: %s [--color-correct] file [iterations] [packetSize]\n", |
| 321 argv[0]); | 266 argv[0]); |
| 322 exit(1); | 267 exit(1); |
| 323 } | 268 } |
| 324 | 269 |
| 325 // Control decode bench iterations and packet size. | 270 // Control decode bench iterations and packet size. |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 391 exit(3); | 336 exit(3); |
| 392 } | 337 } |
| 393 } | 338 } |
| 394 | 339 |
| 395 // Results to stdout. | 340 // Results to stdout. |
| 396 | 341 |
| 397 double averageTime = totalTime / static_cast<double>(iterations); | 342 double averageTime = totalTime / static_cast<double>(iterations); |
| 398 printf("%f %f\n", totalTime, averageTime); | 343 printf("%f %f\n", totalTime, averageTime); |
| 399 return 0; | 344 return 0; |
| 400 } | 345 } |
| OLD | NEW |