Skip to content

Commit d729895

Browse files
committed
Exclude rand from timings
1 parent 0dfbed9 commit d729895

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,16 @@ julia> dyn_uni = Quantity(0.2, mass=1, length=0.5, amount=3)
2323
julia> unitful = convert(Unitful.Quantity, dyn_uni)
2424
0.2 kg m¹ᐟ² mol³
2525

26-
julia> f(x) = x ^ rand(1:10) * 0.3;
26+
julia> f(x, i) = x ^ i * 0.3;
2727

28-
julia> @btime f($dyn_uni);
29-
41.330 ns (0 allocations: 0 bytes)
28+
julia> @btime f($dyn_uni, i) setup=(i=rand(1:10));
29+
9.384 ns (0 allocations: 0 bytes)
3030

31-
julia> @btime f($unitful);
32-
29.542 μs (42 allocations: 1.91 KiB)
31+
julia> @btime f($unitful, i) setup=(i=rand(1:10));
32+
29.667 μs (42 allocations: 1.91 KiB)
3333
```
3434

35-
(Note the μ and n.)
35+
**(Note the μ and n.)**
3636
Here, the DynamicUnits quantity object allows the compiler to build a function that is type stable,
3737
while the Unitful quantity object, which stores its dimensions in the type, requires type inference at runtime.
3838

0 commit comments

Comments
 (0)