Script Preparation code:
x
 
$sourceWidth = 3000;
$sourceHeight = 3000;
$sourceCanvas = document.createElement("canvas");
$sourceCanvas.width = $sourceWidth;
$sourceCanvas.height = $sourceHeight;
$sourceContext = $sourceCanvas.getContext("2d");
$sourceContext.fillStyle = "rgba(0,100,200,1)";
$sourceContext.fillRect(0, 0, $sourceWidth, $sourceHeight);
$destCanvas = document.createElement("canvas");
$destCanvas.width = $sourceWidth;
$destCanvas.height = $sourceHeight;
$destContext = $destCanvas.getContext("2d");
$destContext.imageSmoothingEnabled = false;
Tests:
  • Scaling from a large canvas area to a small canvas area

     
    $destContext.drawImage($sourceCanvas, 0, 0, $sourceWidth, $sourceHeight, 0, 0, 100, 100);
    // Force the drawImage call to be evaluated within this benchmark code:
    $destContext.getImageData(0, 0, 1, 1);
  • Scaling from a large canvas area to a medium canvas area

     
    $destContext.drawImage($sourceCanvas, 0, 0, $sourceWidth, $sourceHeight, 0, 0, 600, 600);
    // Force the drawImage call to be evaluated within this benchmark code:
    $destContext.getImageData(0, 0, 1, 1);
  • Scaling from a large canvas area to a large canvas area (no scaling)

     
    $destContext.drawImage($sourceCanvas, 0, 0, $sourceWidth, $sourceHeight, 0, 0, $sourceWidth, $sourceHeight);
    // Force the drawImage call to be evaluated within this benchmark code:
    $destContext.getImageData(0, 0, 1, 1);
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    Scaling from a large canvas area to a small canvas area
    Scaling from a large canvas area to a medium canvas area
    Scaling from a large canvas area to a large canvas area (no scaling)

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 2 months ago)
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36
Chrome 128 on Linux
View result in a separate tab
Test name Executions per second
Scaling from a large canvas area to a small canvas area 12.0 Ops/sec
Scaling from a large canvas area to a medium canvas area 16.7 Ops/sec
Scaling from a large canvas area to a large canvas area (no scaling) 20.0 Ops/sec