Skip to content

performance on clamp #179

Closed
Closed
@johnnychen94

Description

@johnnychen94

This is expected, but I think it can be optimized.

julia> @btime clamp!($(rand(N0f8, 512, 512)), 0.1, 0.9);
  813.628 μs (0 allocations: 0 bytes)

julia> @btime clamp!($(rand(N0f8, 512, 512)), 0.1N0f8, 0.9N0f8);
  628.583 μs (0 allocations: 0 bytes)

julia> @btime clamp.($(rand(N0f8, 512, 512)), 0.1, 0.9);
  691.843 μs (3 allocations: 2.00 MiB)

julia> @btime clamp.($(rand(N0f8, 512, 512)), 0.1N0f8, 0.9N0f8);
  1.146 ms (3 allocations: 256.19 KiB)

Ref: observed in JuliaImages/ImageContrastAdjustment.jl#28 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions