How to count all unique character frequency in a string?

I wonder if this will be faster and will use less memory if you run this on a large array of strings.

s = "hello"

count_char(s) = begin
  res = Dict{Char, Int}()
  for c in s
      if haskey(res, c)
         res[c] += 1
      else
         res[c] = 1
      end
   end
   res
end

@time count_char(s)
@time count_char(s)
3 Likes