Skip to content

tmap(f, arr) is slower than tmap(f, OutputEltype, arr) or tmap!(f, output, arr) #131

@alfaromartino

Description

@alfaromartino

It seems that tmap is substantially slower than creating a variable output and update it using tmap!. Is this behavior expected or a bug?

function foo(x)
    output = similar(x)
    tmap!(log, output, x)
end

@btime map(log, $x)
@btime tmap(log, $x)
@btime foo($x)

in my machine gives

# x = rand(1_000_000)
  3.185 ms (2 allocations: 7.629 MiB)
  3.031 ms (568 allocations: 16.958 MiB)
  339.091 μs (152 allocations: 7.642 MiB)

# x = rand(10_000_000)
  47.702 ms (2 allocations: 76.294 MiB)
  53.858 ms (569 allocations: 222.665 MiB)
  4.796 ms (152 allocations: 76.307 MiB)

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