Many thanks, guys! Indeed reshape(a,length(a)) is much faster than doing in
the simplest way. However, it brings another question:

When I ran the command:

function myfunc1(corpus)
wc = wordcloud(x = corpus[:])
end

function myfunc2(corpus)
wc = wordcloud(x = reshape(corpus,length(corpus)))
end

I get the following performance:

@time myfunc1(corpus)

1st running:  398.202 milliseconds (452 k allocations: 17406 KB)
2nd running: 144.181 microseconds (374 allocations: 20832 bytes)
3rd running:  99.270 microseconds (374 allocations: 20832 bytes)
4th running:  93.860 microseconds (374 allocations: 20832 bytes)

@time myfunc2(corpus)

1st running:  4.102 milliseconds (2667 allocations: 136 KB)
2nd running: 110.182 microseconds (375 allocations: 20464 bytes)
3rd running:  130.949 microseconds (375 allocations: 20464 bytes)
4th running:  120.142 microseconds (375 allocations: 20464 bytes)

It is clear that it is much faster and occupies much less memory in the
first running. And actually I only need to run it once. However I am
curious to know why would myfunc2 be slower than the myfunc1 as the number
of running increase?

Thanks for everything!

Best,

Charles

On 10 September 2015 at 19:24, Steven G. Johnson <stevenj....@gmail.com>
wrote:

>
>
> On Thursday, September 10, 2015 at 10:39:58 AM UTC-4, Seth wrote:
>>
>> would vec() also work for you? It's supposed to be pretty fast.
>>
>>> <http://www.imedea.uib-csic.es/~charles>
>>>
>>
> vec(a) is equivalent to reshape(a, length(a)), and is fast because it
> doesn't make a copy of the data.
>



-- 
Um axé! :)

--
Charles Novaes de Santana, PhD
http://www.imedea.uib-csic.es/~charles

Reply via email to