# Unitful.jl without parametrizing types on units?

**URL:** <https://discourse.julialang.org/t/unitful-jl-without-parametrizing-types-on-units/99869>\
**Category:** General Usage\
**Tags:** question, unitful\
**Created:** [June 5, 2023, 5:08am UTC](https://discourse.julialang.org/t/unitful-jl-without-parametrizing-types-on-units/99869 "2023-06-05T05:08:41Z")\
**Posts on this page:** 1\
**Showing post:** 21

<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:** [June 6, 2023, 5:49pm UTC](https://discourse.julialang.org/t/unitful-jl-without-parametrizing-types-on-units/99869/21 "2023-06-06T17:49:20Z")

</div>

Using `@btime randn(5) .* Dimensions(mass=2/5, length=2)` as a benchmark, I see a pretty big improvement going to `Int8` instead of `Int`. It won’t make much difference for scalars, but for vectors, it cuts allocations by 75% and time by 19%.

```julia
#before:
julia> @btime randn(500) .* Dimensions(mass=2/5, length=2);
  17.086 μs (1012 allocations: 145.22 KiB)
# after:
julia> @btime randn(500) .* Dimensions(mass=2/5, length=2);
  13.984 μs (1011 allocations: 39.77 KiB)

```

---

_[View the full topic](https://discourse.julialang.org/t/unitful-jl-without-parametrizing-types-on-units/99869)._
