benchmarks comparing the rust image processing ecosystem
| -rw-r--r-- | Cargo.toml | 1 | ||||
| -rw-r--r-- | benches/blur.rs | 14 | ||||
| -rw-r--r-- | blur.svg | 2 |
3 files changed, 15 insertions, 2 deletions
@@ -8,6 +8,7 @@ edition = "2021" [dependencies] blud = "0.0.0" blurslice = "0.1.0" +fastblur = "0.1.1" fimg = { version = "0.4.23", features = ["text", "blur", "scale"] } iai = { git = "https://github.com/bend-n/iai", version = "0.1.1" } image = { version = "0.24.7", default-features = false, features = ["png"] } diff --git a/benches/blur.rs b/benches/blur.rs index 4444334..a126a74 100644 --- a/benches/blur.rs +++ b/benches/blur.rs @@ -1,3 +1,4 @@ +#![feature(array_chunks)] use fimg::Image; use image::RgbImage; @@ -27,6 +28,17 @@ pub fn image() { )); } +pub fn fastblur() { + let mut data = iai::black_box( + include_bytes!("../small_data.imgbuf") + .array_chunks::<3>() + .copied() + .collect::<Vec<_>>(), + ); + fastblur::gaussian_blur(&mut data, SIZE as usize, SIZE as usize, 15.0); + iai::black_box(&data); +} + pub fn blurslice() { let mut data = iai::black_box(include_bytes!("../small_data.imgbuf").to_vec()); blurslice::gaussian_blur_bytes::<3>(&mut data, SIZE as usize, SIZE as usize, 15.0).unwrap(); @@ -53,4 +65,4 @@ pub fn fimg() { iai::black_box(&i); } -iai::main!(blud, imageproc, fimg, image); +iai::main!(blud, imageproc, fimg, image, fastblur); @@ -1 +1 @@ -<svg xmlns="http://www.w3.org/2000/svg" width="480" height="480"><path fill="#0d1117" d="M0 0h480v480H0z"/><path fill="none" stroke="#1F2430" stroke-dasharray="5,8" stroke-width="2" d="M89.31 463.22h365.51" class="gridline" color="#000"/><g fill="none" stroke="currentColor" color="#000"><path stroke="#E6EDF3" d="M89.31 463.22h9m356.51 0h-9"/><text fill="#E6EDF3" stroke="none" font-family="Arial" font-size="12" text-anchor="end" transform="translate(80.92 467.12)"><tspan> 0</tspan></text></g><path fill="none" stroke="#1F2430" stroke-dasharray="5,8" stroke-width="2" d="M89.31 413.19h365.51" class="gridline" color="#000"/><g fill="none" stroke="currentColor" color="#000"><path stroke="#E6EDF3" d="M89.31 413.19h9m356.51 0h-9"/><text fill="#E6EDF3" stroke="none" font-family="Arial" font-size="12" text-anchor="end" transform="translate(80.92 417.09)"><tspan> 1x10</tspan><tspan dy="-6" font-size="9.6">9</tspan></text></g><path fill="none" stroke="#1F2430" stroke-dasharray="5,8" stroke-width="2" d="M89.31 363.17h365.51" class="gridline" color="#000"/><g fill="none" stroke="currentColor" color="#000"><path stroke="#E6EDF3" d="M89.31 363.17h9m356.51 0h-9"/><text fill="#E6EDF3" stroke="none" font-family="Arial" font-size="12" text-anchor="end" transform="translate(80.92 367.07)"><tspan> 2x10</tspan><tspan dy="-6" font-size="9.6">9</tspan></text></g><path fill="none" stroke="#1F2430" stroke-dasharray="5,8" stroke-width="2" d="M89.31 313.14h365.51" class="gridline" color="#000"/><g fill="none" stroke="currentColor" color="#000"><path stroke="#E6EDF3" d="M89.31 313.14h9m356.51 0h-9"/><text fill="#E6EDF3" stroke="none" font-family="Arial" font-size="12" text-anchor="end" transform="translate(80.92 317.04)"><tspan> 3x10</tspan><tspan dy="-6" font-size="9.6">9</tspan></text></g><path fill="none" stroke="#1F2430" stroke-dasharray="5,8" stroke-width="2" d="M89.31 263.11h365.51" class="gridline" color="#000"/><g fill="none" stroke="currentColor" color="#000"><path stroke="#E6EDF3" d="M89.31 263.11h9m356.51 0h-9"/><text fill="#E6EDF3" stroke="none" font-family="Arial" font-size="12" text-anchor="end" transform="translate(80.92 267.01)"><tspan> 4x10</tspan><tspan dy="-6" font-size="9.6">9</tspan></text></g><path fill="none" stroke="#1F2430" stroke-dasharray="5,8" stroke-width="2" d="M89.31 213.09h365.51" class="gridline" color="#000"/><g fill="none" stroke="currentColor" color="#000"><path stroke="#E6EDF3" d="M89.31 213.09h9m356.51 0h-9"/><text fill="#E6EDF3" stroke="none" font-family="Arial" font-size="12" text-anchor="end" transform="translate(80.92 216.99)"><tspan> 5x10</tspan><tspan dy="-6" font-size="9.6">9</tspan></text></g><path fill="none" stroke="#1F2430" stroke-dasharray="5,8" stroke-width="2" d="M89.31 163.06h365.51" class="gridline" color="#000"/><g fill="none" stroke="currentColor" color="#000"><path stroke="#E6EDF3" d="M89.31 163.06h9m356.51 0h-9"/><text fill="#E6EDF3" stroke="none" font-family="Arial" font-size="12" text-anchor="end" transform="translate(80.92 166.96)"><tspan> 6x10</tspan><tspan dy="-6" font-size="9.6">9</tspan></text></g><path fill="none" stroke="#1F2430" stroke-dasharray="5,8" stroke-width="2" d="M89.31 113.04h220.85m136.27 0h8.39" class="gridline" color="#000"/><g fill="none" stroke="currentColor" color="#000"><path stroke="#E6EDF3" d="M89.31 113.04h9m356.51 0h-9"/><text fill="#E6EDF3" stroke="none" font-family="Arial" font-size="12" text-anchor="end" transform="translate(80.92 116.94)"><tspan> 7x10</tspan><tspan dy="-6" font-size="9.6">9</tspan></text></g><path fill="none" stroke="#1F2430" stroke-dasharray="5,8" stroke-width="2" d="M89.31 63.01h365.51" class="gridline" color="#000"/><g fill="none" stroke="currentColor" color="#000"><path stroke="#E6EDF3" d="M89.31 63.01h9m356.51 0h-9"/><text fill="#E6EDF3" stroke="none" font-family="Arial" font-size="12" text-anchor="end" transform="translate(80.92 66.91)"><tspan> 8x10</tspan><tspan dy="-6" font-size="9.6">9</tspan></text></g><path fill="none" stroke="#E6EDF3" d="M89.31 63.01v400.21h365.51V63.01H89.31Z" color="#000"/><text fill="#E6EDF3" color="#000" font-family="Verdana" font-size="18" text-anchor="middle" transform="rotate(-90 142.125 120.995)"><tspan>cycles</tspan></text><text fill="#E6EDF3" stroke-width="2" color="#000" font-family="Verdana" font-size="14" text-anchor="end" transform="translate(378.69 87.06)"><tspan>fimg</tspan></text><g fill="none" stroke="currentColor" stroke-width="2" color="#000"><path fill="#73D0FF" stroke="none" d="M388.48 87.76h48.16v-10.5h-48.16z" shape-rendering="crispEdges"/><path stroke="#1A1F29" d="M388.48 87.76h48.16v-10.5h-48.16v10.5Z"/></g><g fill="none" stroke="currentColor" stroke-width="2" color="#000"><path fill="#73D0FF" stroke="none" d="M180.69 463.22h45.7v-33.76h-45.7z" shape-rendering="crispEdges"/><path stroke="#1A1F29" d="M180.69 463.22v-33.75h45.69v33.75h-45.69Z"/></g><text fill="#E6EDF3" stroke-width="2" color="#000" font-family="Verdana" font-size="14" text-anchor="end" transform="translate(378.69 108.06)"><tspan>imgproc</tspan></text><g fill="none" stroke="currentColor" stroke-width="2" color="#000"><path fill="#FFD173" stroke="none" d="M388.48 108.76h48.16v-10.5h-48.16z" shape-rendering="crispEdges"/><path stroke="#1A1F29" d="M388.48 108.76h48.16v-10.5h-48.16v10.5Z"/></g><g fill="none" stroke="currentColor" stroke-width="2" color="#000"><path fill="#FFD173" stroke="none" d="M226.38 463.22h45.7V140.46h-45.7z" shape-rendering="crispEdges"/><path stroke="#1A1F29" d="M226.38 463.22V140.47h45.69v322.75h-45.69Z"/></g><text fill="#E6EDF3" stroke-width="2" color="#000" font-family="Verdana" font-size="14" text-anchor="end" transform="translate(378.69 129.06)"><tspan>image</tspan></text><g fill="none" stroke="currentColor" stroke-width="2" color="#000"><path fill="#D5FF80" stroke="none" d="M388.48 129.76h48.16v-10.5h-48.16z" shape-rendering="crispEdges"/><path stroke="#1A1F29" d="M388.48 129.76h48.16v-10.5h-48.16v10.5Z"/></g><g fill="none" stroke="currentColor" stroke-width="2" color="#000"><path fill="#D5FF80" stroke="none" d="M272.07 463.22h45.69V98.35h-45.69z" shape-rendering="crispEdges"/><path stroke="#1A1F29" d="M272.07 463.22V98.36h45.68v364.86h-45.68Z"/></g><text fill="#E6EDF3" stroke-width="2" color="#000" font-family="Verdana" font-size="14" text-anchor="end" transform="translate(378.69 150.06)"><tspan>blud</tspan></text><g fill="none" stroke="currentColor" stroke-width="2" color="#000"><path fill="#F27983" stroke="none" d="M388.48 150.76h48.16v-10.5h-48.16z" shape-rendering="crispEdges"/><path stroke="#1A1F29" d="M388.48 150.76h48.16v-10.5h-48.16v10.5Z"/></g><g fill="none" stroke="currentColor" stroke-width="2" color="#000"><path fill="#F27983" stroke="none" d="M317.75 463.22h45.7v-33.9h-45.7z" shape-rendering="crispEdges"/><path stroke="#1A1F29" d="M317.75 463.22v-33.89h45.69v33.89h-45.69Z"/></g><path fill="none" stroke="#E6EDF3" d="M89.31 63.01v400.21h365.51V63.01H89.31Z" color="#000"/><text fill="#E6EDF3" color="#000" font-family="Verdana" font-size="18" text-anchor="middle" transform="translate(272.06 32.86)"><tspan>gaussian blur</tspan></text></svg>
\ No newline at end of file +<svg xmlns="http://www.w3.org/2000/svg" width="480" height="480"><path fill="#0d1117" d="M0 0h480v480H0z"/><path fill="none" stroke="#1F2430" stroke-dasharray="5,8" stroke-width="2" d="M89.31 463.22h365.51" class="gridline" color="#000"/><g fill="none" stroke="currentColor" color="#000"><path stroke="#E6EDF3" d="M89.31 463.22h9m356.51 0h-9"/><text fill="#E6EDF3" stroke="none" font-family="Arial" font-size="12" text-anchor="end" transform="translate(80.92 467.12)"><tspan> 0</tspan></text></g><path fill="none" stroke="#1F2430" stroke-dasharray="5,8" stroke-width="2" d="M89.31 413.19h365.51" class="gridline" color="#000"/><g fill="none" stroke="currentColor" color="#000"><path stroke="#E6EDF3" d="M89.31 413.19h9m356.51 0h-9"/><text fill="#E6EDF3" stroke="none" font-family="Arial" font-size="12" text-anchor="end" transform="translate(80.92 417.09)"><tspan> 1x10</tspan><tspan dy="-6" font-size="9.6">9</tspan></text></g><path fill="none" stroke="#1F2430" stroke-dasharray="5,8" stroke-width="2" d="M89.31 363.17h365.51" class="gridline" color="#000"/><g fill="none" stroke="currentColor" color="#000"><path stroke="#E6EDF3" d="M89.31 363.17h9m356.51 0h-9"/><text fill="#E6EDF3" stroke="none" font-family="Arial" font-size="12" text-anchor="end" transform="translate(80.92 367.07)"><tspan> 2x10</tspan><tspan dy="-6" font-size="9.6">9</tspan></text></g><path fill="none" stroke="#1F2430" stroke-dasharray="5,8" stroke-width="2" d="M89.31 313.14h365.51" class="gridline" color="#000"/><g fill="none" stroke="currentColor" color="#000"><path stroke="#E6EDF3" d="M89.31 313.14h9m356.51 0h-9"/><text fill="#E6EDF3" stroke="none" font-family="Arial" font-size="12" text-anchor="end" transform="translate(80.92 317.04)"><tspan> 3x10</tspan><tspan dy="-6" font-size="9.6">9</tspan></text></g><path fill="none" stroke="#1F2430" stroke-dasharray="5,8" stroke-width="2" d="M89.31 263.11h365.51" class="gridline" color="#000"/><g fill="none" stroke="currentColor" color="#000"><path stroke="#E6EDF3" d="M89.31 263.11h9m356.51 0h-9"/><text fill="#E6EDF3" stroke="none" font-family="Arial" font-size="12" text-anchor="end" transform="translate(80.92 267.01)"><tspan> 4x10</tspan><tspan dy="-6" font-size="9.6">9</tspan></text></g><path fill="none" stroke="#1F2430" stroke-dasharray="5,8" stroke-width="2" d="M89.31 213.09h365.51" class="gridline" color="#000"/><g fill="none" stroke="currentColor" color="#000"><path stroke="#E6EDF3" d="M89.31 213.09h9m356.51 0h-9"/><text fill="#E6EDF3" stroke="none" font-family="Arial" font-size="12" text-anchor="end" transform="translate(80.92 216.99)"><tspan> 5x10</tspan><tspan dy="-6" font-size="9.6">9</tspan></text></g><path fill="none" stroke="#1F2430" stroke-dasharray="5,8" stroke-width="2" d="M89.31 163.06h211.06m146.06 0h8.39" class="gridline" color="#000"/><g fill="none" stroke="currentColor" color="#000"><path stroke="#E6EDF3" d="M89.31 163.06h9m356.51 0h-9"/><text fill="#E6EDF3" stroke="none" font-family="Arial" font-size="12" text-anchor="end" transform="translate(80.92 166.96)"><tspan> 6x10</tspan><tspan dy="-6" font-size="9.6">9</tspan></text></g><path fill="none" stroke="#1F2430" stroke-dasharray="5,8" stroke-width="2" d="M89.31 113.04h211.06m146.06 0h8.39" class="gridline" color="#000"/><g fill="none" stroke="currentColor" color="#000"><path stroke="#E6EDF3" d="M89.31 113.04h9m356.51 0h-9"/><text fill="#E6EDF3" stroke="none" font-family="Arial" font-size="12" text-anchor="end" transform="translate(80.92 116.94)"><tspan> 7x10</tspan><tspan dy="-6" font-size="9.6">9</tspan></text></g><path fill="none" stroke="#1F2430" stroke-dasharray="5,8" stroke-width="2" d="M89.31 63.01h365.51" class="gridline" color="#000"/><g fill="none" stroke="currentColor" color="#000"><path stroke="#E6EDF3" d="M89.31 63.01h9m356.51 0h-9"/><text fill="#E6EDF3" stroke="none" font-family="Arial" font-size="12" text-anchor="end" transform="translate(80.92 66.91)"><tspan> 8x10</tspan><tspan dy="-6" font-size="9.6">9</tspan></text></g><path fill="none" stroke="#E6EDF3" d="M89.31 63.01v400.21h365.51V63.01H89.31Z" color="#000"/><text fill="#E6EDF3" color="#000" font-family="Verdana" font-size="18" text-anchor="middle" transform="rotate(-90 142.125 120.995)"><tspan>cycles</tspan></text><text fill="#E6EDF3" stroke-width="2" color="#000" font-family="Verdana" font-size="14" text-anchor="end" transform="translate(378.69 87.06)"><tspan>fimg</tspan></text><g fill="none" stroke="currentColor" stroke-width="2" color="#000"><path fill="#73D0FF" stroke="none" d="M388.48 87.76h48.16v-10.5h-48.16z" shape-rendering="crispEdges"/><path stroke="#1A1F29" d="M388.48 87.76h48.16v-10.5h-48.16v10.5Z"/></g><g fill="none" stroke="currentColor" stroke-width="2" color="#000"><path fill="#73D0FF" stroke="none" d="M180.69 463.22h36.56v-33.66h-36.56z" shape-rendering="crispEdges"/><path stroke="#1A1F29" d="M180.69 463.22v-33.65h36.55v33.65h-36.55Z"/></g><text fill="#E6EDF3" stroke-width="2" color="#000" font-family="Verdana" font-size="14" text-anchor="end" transform="translate(378.69 108.06)"><tspan>imgproc</tspan></text><g fill="none" stroke="currentColor" stroke-width="2" color="#000"><path fill="#FFD173" stroke="none" d="M388.48 108.76h48.16v-10.5h-48.16z" shape-rendering="crispEdges"/><path stroke="#1A1F29" d="M388.48 108.76h48.16v-10.5h-48.16v10.5Z"/></g><g fill="none" stroke="currentColor" stroke-width="2" color="#000"><path fill="#FFD173" stroke="none" d="M217.24 463.22h36.56V140.46h-36.56z" shape-rendering="crispEdges"/><path stroke="#1A1F29" d="M217.24 463.22V140.47h36.55v322.75h-36.55Z"/></g><text fill="#E6EDF3" stroke-width="2" color="#000" font-family="Verdana" font-size="14" text-anchor="end" transform="translate(378.69 129.06)"><tspan>image</tspan></text><g fill="none" stroke="currentColor" stroke-width="2" color="#000"><path fill="#D5FF80" stroke="none" d="M388.48 129.76h48.16v-10.5h-48.16z" shape-rendering="crispEdges"/><path stroke="#1A1F29" d="M388.48 129.76h48.16v-10.5h-48.16v10.5Z"/></g><g fill="none" stroke="currentColor" stroke-width="2" color="#000"><path fill="#D5FF80" stroke="none" d="M253.79 463.22h36.56V98.35h-36.56z" shape-rendering="crispEdges"/><path stroke="#1A1F29" d="M253.79 463.22V98.36h36.55v364.86h-36.55Z"/></g><text fill="#E6EDF3" stroke-width="2" color="#000" font-family="Verdana" font-size="14" text-anchor="end" transform="translate(378.69 150.06)"><tspan>blud</tspan></text><g fill="none" stroke="currentColor" stroke-width="2" color="#000"><path fill="#F27983" stroke="none" d="M388.48 150.76h48.16v-10.5h-48.16z" shape-rendering="crispEdges"/><path stroke="#1A1F29" d="M388.48 150.76h48.16v-10.5h-48.16v10.5Z"/></g><g fill="none" stroke="currentColor" stroke-width="2" color="#000"><path fill="#F27983" stroke="none" d="M290.34 463.22h36.56v-33.9h-36.56z" shape-rendering="crispEdges"/><path stroke="#1A1F29" d="M290.34 463.22v-33.89h36.55v33.89h-36.55Z"/></g><text fill="#E6EDF3" stroke-width="2" color="#000" font-family="Verdana" font-size="14" text-anchor="end" transform="translate(378.69 171.06)"><tspan>fastblur</tspan></text><g fill="none" stroke="currentColor" stroke-width="2" color="#000"><path fill="#DFBFFF" stroke="none" d="M388.48 171.76h48.16v-10.5h-48.16z" shape-rendering="crispEdges"/><path stroke="#1A1F29" d="M388.48 171.76h48.16v-10.5h-48.16v10.5Z"/></g><g fill="none" stroke="currentColor" stroke-width="2" color="#000"><path fill="#DFBFFF" stroke="none" d="M326.89 463.22h36.56v-43.98h-36.56z" shape-rendering="crispEdges"/><path stroke="#1A1F29" d="M326.89 463.22v-43.97h36.55v43.97h-36.55Z"/></g><path fill="none" stroke="#E6EDF3" d="M89.31 63.01v400.21h365.51V63.01H89.31Z" color="#000"/><text fill="#E6EDF3" color="#000" font-family="Verdana" font-size="18" text-anchor="middle" transform="translate(272.06 32.86)"><tspan>gaussian blur</tspan></text></svg>
\ No newline at end of file |