Decorated intervals are slow
It's expected that they're slower, but probably not this slow:
julia> using IntervalArithmetic, BenchmarkTools
julia> x = 0.1..0.2; y = 0.3..0.4;
julia> @btime $x + $y
x 6.534 ns (0 allocations: 0 bytes)
[0.399999, 0.600001]
julia> x2 = DecoratedInterval(x); y2 = DecoratedInterval(y);
julia> @btime $x2 + $y2
16.818 ns (0 allocations: 0 bytes)
[0.399999, 0.600001]
I might be completely wrong, but here is a speculation:
For bare intervals, the inner constructor Interval doesn't do any checks, those are delegated to the external function interval. I think this was motivated for efficiency reasons. For DecoratedInterval, the internal constructor does several checks, maybe this is the reason why decorated intervals are slower?
I think it might be good to have a similar "internal-without-checks" vs "external-with-checks" mechanism also for decorated intervals, at least for testing purposes.
Now I get
julia> @btime $(Ref(x))[] + $(Ref(y))[]
8.903 ns (0 allocations: 0 bytes)
[0.399999, 0.600001]
julia> @btime $(Ref(x2))[] + $(Ref(y2))[]
13.377 ns (0 allocations: 0 bytes)
[0.399999, 0.600001]
which doesn't seem so bad.
But you're probably right, yes.
Closing this issue since on master:
julia> @btime $(Ref(x))[] + $(Ref(y))[]
5.875 ns (0 allocations: 0 bytes)
[0.3999999, 0.600001]
julia> @btime $(Ref(x2))[] + $(Ref(y2))[]
8.842 ns (0 allocations: 0 bytes)
[0.3999999, 0.600001]_com