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

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

Issue 1145373003: Copy SharedBuffer before calling decodeImageData (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@benchmarkEmail
Patch Set: Rebase Created 5 years, 5 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 #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:
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 if (!data.get() || !data->size()) { 358 if (!data.get() || !data->size()) {
359 fprintf(stderr, "Error reading image data from [%s]\n", argv[1]); 359 fprintf(stderr, "Error reading image data from [%s]\n", argv[1]);
360 exit(2); 360 exit(2);
361 } 361 }
362 362
363 // Image decode bench for iterations. 363 // Image decode bench for iterations.
364 364
365 double totalTime = 0.0; 365 double totalTime = 0.0;
366 366
367 for (size_t i = 0; i < iterations; ++i) { 367 for (size_t i = 0; i < iterations; ++i) {
368 // Copy the SharedBuffer. Note that we do not want to call
369 // SharedBuffer::copy, which would merge all the segments. We want this
370 // to look just like it would receiving partial data off the web.
371 // After this call, data will have its segments merged, but not tempData .
372 RefPtr<SharedBuffer> tempData = SharedBuffer::create(data->data(), data- >size());
373
368 double startTime = getCurrentTime(); 374 double startTime = getCurrentTime();
369 bool decoded = decodeImageData(data.get(), applyColorCorrection); 375 bool decoded = decodeImageData(tempData.get(), applyColorCorrection);
370 double elapsedTime = getCurrentTime() - startTime; 376 double elapsedTime = getCurrentTime() - startTime;
371 totalTime += elapsedTime; 377 totalTime += elapsedTime;
372 if (!decoded) { 378 if (!decoded) {
373 fprintf(stderr, "Image decode failed [%s]\n", argv[1]); 379 fprintf(stderr, "Image decode failed [%s]\n", argv[1]);
374 exit(3); 380 exit(3);
375 } 381 }
376 } 382 }
377 383
378 // Results to stdout. 384 // Results to stdout.
379 385
380 double averageTime = totalTime / static_cast<double>(iterations); 386 double averageTime = totalTime / static_cast<double>(iterations);
381 printf("%f %f\n", totalTime, averageTime); 387 printf("%f %f\n", totalTime, averageTime);
382 return 0; 388 return 0;
383 } 389 }
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