Skip to content

Commit

Permalink
- added some testing results as a comment to clarify motivation for u…
Browse files Browse the repository at this point in the history
…int64 storage
  • Loading branch information
amkrajewski committed Feb 20, 2024
1 parent e36c4fb commit bb3917f
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/nimcso/bitArrayAutoconfigured.nim
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ func divUp(a, b: int): int =

const lenInt64 = elementN.divUp(64)
echo "Using ", lenInt64, " uint64s to store ", elementN, " elements."
# Side Note: There is a good reason to use uint64 even if the problem is smaller. The reason is performance. A 64-bit CPU is much better at handling 64-bit numbers; thus even if you hard-code the type
# of the bit array values to be uint8 or uint16, the compiler will likely align them to fill 64-bit boundaries anyways, so there won't be any memory savings, while it will be slightly slower. E.g.,
# [1, uint64] -> CPU Time [Expanding to elementN nodes 1000 times from empty] 1011.2us | -as with default config.yaml at step 24 -> 222.3 MB RAM
# [3, utin16] -> CPU Time [Expanding to elementN nodes 1000 times from empty] 1049.2us | -as with default config.yaml at step 24 -> 223.7 MB RAM

type BitArray* = object
## Creates an array of bits all packed in together.
Expand Down

0 comments on commit bb3917f

Please sign in to comment.