Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

24
LINES

< > BotCompany Repo | #1034533 // (b|B)enchDrawingImageOnImageWithAlpha

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (5548L/31K).

1  
// Results for ThinkPad in MPixels/s:
2  
//   852 (alpha 0) / 158 (alpha 0x80) / 401 (alpha 0xFF)
3  
4  
sclass BenchDrawingImageOnImageWithAlpha {
5  
  int w = 1000, h = w;
6  
  long nanos;
7  
  settable int alphaValue = 0x80; // alpha 0 (draw nothing) and alpha 255 (draw opaque) are faster than other values
8  
  
9  
  run {
10  
    int[] pixels = repIntAsArray(w*h, -1);
11  
    var img = bufferedImageWithoutAlpha(w, h, pixels);
12  
    pixels = repIntAsArray(w*h, alphaValue << 24);
13  
    var img2 = bufferedImageWithAlpha(w, h, pixels);
14  
    var g = graphics(img);
15  
    nanos = benchFor5("draw " + nPixels(w*h), -> drawImage(g, img2));
16  
    print("Fastest result for alpha " + alphaValue + ": Can draw " + n2(w*h*1000/nanos) + " MPixels/s");
17  
  }
18  
}
19  
20  
svoid benchDrawingImageOnImageWithAlpha() {
21  
  new BenchDrawingImageOnImageWithAlpha().alphaValue(0).run();
22  
  new BenchDrawingImageOnImageWithAlpha().alphaValue(0x80).run();
23  
  new BenchDrawingImageOnImageWithAlpha().alphaValue(0xFF).run();
24  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 4 computer(s): bhatertpkbcr, ekrmjmnbrukm, mowyntqkapby, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1034533
Snippet name: (b|B)enchDrawingImageOnImageWithAlpha
Eternal ID of this version: #1034533/9
Text MD5: 16ab6f41ef4002ec725de08c21474d7b
Transpilation MD5: 98c62908a229ff04572ca952607b48be
Author: stefan
Category: javax / imaging
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-02-11 14:10:00
Source code size: 978 bytes / 24 lines
Pitched / IR pitched: No / No
Views / Downloads: 200 / 356
Version history: 8 change(s)
Referenced in: [show references]