# Count words challenge

**URL:** <https://discourse.julialang.org/t/count-words-challenge/57221>\
**Category:** Performance\
**Created:** [March 15, 2021, 5:52pm UTC](https://discourse.julialang.org/t/count-words-challenge/57221 "2021-03-15T17:52:37Z")\
**Posts on this page:** 5\
**Page:** 2

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [March 15, 2021, 9:51pm UTC](https://discourse.julialang.org/t/count-words-challenge/57221/21 "2021-03-15T21:51:17Z")

</div>

> [@ericphanson](#):
>
> Adding a view to your code doesn’t seem to change the timings there for me though.

I used `@views` in my function declaration, so you don’t need `@view` in the body of my function — all slices are views.

---

<div class="post-metadata">

**Author:** ![ericphanson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ericphanson/32/215186_2.png) [@ericphanson](https://discourse.julialang.org/u/ericphanson)\
**Post date:** [March 15, 2021, 9:52pm UTC](https://discourse.julialang.org/t/count-words-challenge/57221/22 "2021-03-15T21:52:34Z")

</div>

Ahh that would explain it! I think the Automata code expands to basically the same loop as your code, which would explain getting the same benchmark results.

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [March 16, 2021, 12:37am UTC](https://discourse.julialang.org/t/count-words-challenge/57221/23 "2021-03-16T00:37:49Z")

</div>

> [@alemelis](#):
>
> In short, the idea is to benchmark different languages in counting words frequency for long text files.

Note that they perform the benchmark by running `julia foo.jl`, which means it includes startup/compilation time. This probably makes the results much less interesting since they don’t reflect how Julia is actually used for performance-critical problems.

I [commented on this](https://github.com/benhoyt/countwords/pull/26/files#r594788045) in the PR.

---

<div class="post-metadata">

**Author:** ![Oscar\_Smith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oscar_smith/32/25343_2.png) [@Oscar\_Smith](https://discourse.julialang.org/u/Oscar_Smith)\
**Post date:** [March 16, 2021, 12:40am UTC](https://discourse.julialang.org/t/count-words-challenge/57221/24 "2021-03-16T00:40:58Z")

</div>

Also, it might be worth pointing out that `AbstractArray` hashing was way slower than it should have been until very recently. 1.7 will be about 6x faster for hashing small `Arrray`s (and at least 2x faster for all `AbstractArray`s).

---

<div class="post-metadata">

**Author:** ![ImreSamu](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/imresamu/32/20677_2.png) [@ImreSamu](https://discourse.julialang.org/u/ImreSamu)\
**Post date:** [March 23, 2021, 2:10pm UTC](https://discourse.julialang.org/t/count-words-challenge/57221/25 "2021-03-23T14:10:06Z")

</div>

Ouch … as I see this is based on `julia version 1.4.1`

- [https://github.com/benhoyt/countwords/blob/master/versions.txt#L15](https://github.com/benhoyt/countwords/blob/master/versions.txt#L15)

my theory: on ubuntu:20.04 - the default `apt-get install julia`  
has a same version → `Ubuntu ⛬ julia/1.4.1+dfsg-1`  
So this is not an official “binary”

[Previous page](https://discourse.julialang.org/t/count-words-challenge/57221.md?page=1)
