• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

JuliaLang / julia / #37743
77%

Build:
DEFAULT BRANCH: master
Ran 10 Apr 2024 10:21AM UTC
Jobs 1
Files 361
Run time 1min
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

09 Apr 2024 09:06PM UTC coverage: 81.402% (-0.02%) from 81.42%
#37743

push

local

web-flow
Improve performance of `ncodeunits(::Char)` (#54001)

This improves performance of `ncodeunits(::Char)` by simply counting the
number of non-zero bytes (except for `\0`, which is encoded as all zero
bytes). For a performance comparison, see [this gist](
https://gist.github.com/Seelengrab/ebb02d4b8d754700c2869de8daf88cad);
there's an up to 10x improvement here for collections of `Char`, with a
minor improvement for single `Char` (with much smaller spread). The
version in this PR is called `nbytesencoded` in the benchmarks.

Correctness has been verified with Supposition.jl, using the existing
implementation as an oracle:

```julia
julia> using Supposition

julia> const chars = Data.Characters()

julia> @check max_examples=1_000_000 function bytesenc(i=Data.Integers{UInt32}())
           c = reinterpret(Char, i)
           ncodeunits(c) == nbytesdiv(c)
       end;
Test Summary: | Pass  Total  Time
bytesenc      |    1      1  1.0s

julia> ncodeunits('\0') == nbytesencoded('\0')
true
```

Let's see if CI agrees!

Notably, neither the existing nor the new implementation check whether
the given `Char` is valid or not, since the only thing that matters is
how many bytes are written out.

---------

Co-authored-by: Sukera <Seelengrab@users.noreply.github.com>

4 of 4 new or added lines in 1 file covered. (100.0%)

54 existing lines in 8 files now uncovered.

70709 of 86864 relevant lines covered (81.4%)

15630252.81 hits per line

Uncovered Existing Lines

Lines Coverage ∆ File
1
90.95
-0.41% stdlib/Random/src/generation.jl
1
80.01
-0.06% stdlib/LinearAlgebra/src/triangular.jl
1
72.03
-0.85% base/partr.jl
2
25.0
-4.03% base/atomics.jl
3
64.86
-8.11% base/gcutils.jl
5
67.18
-1.53% base/client.jl
19
66.39
-0.92% base/loading.jl
22
73.7
-0.09% base/compiler/inferencestate.jl
Jobs
ID Job ID Ran Files Coverage
1 #37743.1 10 Apr 2024 10:21AM UTC 361
81.4
Source Files on build #37743
  • Tree
  • List 361
  • Changed 270
  • Source Changed 0
  • Coverage Changed 21
Coverage ∆ File Lines Relevant Covered Missed Hits/Line
  • Back to Repo
  • d183ee1b on github
  • Prev Build on master
  • Next Build on master
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc