Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement hash function #5

Merged
merged 1 commit into from
May 21, 2022
Merged

Implement hash function #5

merged 1 commit into from
May 21, 2022

Conversation

jmert
Copy link
Owner

@jmert jmert commented May 21, 2022

Duplicates improvement made to Base's Enums: JuliaLang/julia#30500

Before:

julia> @bitflag Flag1 flag1=0 flag2 flag3 flag4

julia> @benchmark hash(flag1)
BenchmarkTools.Trial: 10000 samples with 1000 evaluations.
 Range (min  max):  11.035 ns  52.801 ns  ┊ GC (min  max): 0.00%  0.00%
 Time  (median):     15.714 ns              ┊ GC (median):    0.00%
 Time  (mean ± σ):   16.003 ns ±  1.305 ns  ┊ GC (mean ± σ):  0.00% ± 0.00%

                                        ▁▃ █▁▄        ▁
  ▂▂▂▁▁▁▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▃▃▃▃▃▄▂▃▄██▆███▃▃▂▂▂▂▆▅█▆▆█▅▃▂ ▃
  11 ns           Histogram: frequency by time        17.5 ns <

 Memory estimate: 0 bytes, allocs estimate: 0.

After:

julia> @benchmark hash(flag1)
BenchmarkTools.Trial: 10000 samples with 1000 evaluations.
 Range (min  max):  1.397 ns  33.455 ns  ┊ GC (min  max): 0.00%  0.00%
 Time  (median):     4.819 ns              ┊ GC (median):    0.00%
 Time  (mean ± σ):   4.907 ns ±  1.042 ns  ┊ GC (mean ± σ):  0.00% ± 0.00%

                                               ██    ▅▅
  ▂▁▁▁▁▂▂▂▁▁▁▁▂▃▂▁▁▁▁▂▂▁▁▁▂▃▃▂▁▁▁▂▂▂▁▁▁▁▂▂▂▁▁▃███▆▁▂▄███▃▁▂▂ ▃
  1.4 ns         Histogram: frequency by time        5.66 ns <

 Memory estimate: 0 bytes, allocs estimate: 0.

Duplicates improvement made to Base's Enums: JuliaLang/julia#30500

**Before:**
```julia
julia> @bitflag Flag1 flag1=0 flag2 flag3 flag4

julia> @benchmark hash(flag1)
BenchmarkTools.Trial: 10000 samples with 1000 evaluations.
 Range (min … max):  11.035 ns … 52.801 ns  ┊ GC (min … max): 0.00% … 0.00%
 Time  (median):     15.714 ns              ┊ GC (median):    0.00%
 Time  (mean ± σ):   16.003 ns ±  1.305 ns  ┊ GC (mean ± σ):  0.00% ± 0.00%

                                        ▁▃ █▁▄        ▁
  ▂▂▂▁▁▁▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▃▃▃▃▃▄▂▃▄██▆███▃▃▂▂▂▂▆▅█▆▆█▅▃▂ ▃
  11 ns           Histogram: frequency by time        17.5 ns <

 Memory estimate: 0 bytes, allocs estimate: 0.
```

**After:**
```julia
julia> @benchmark hash(flag1)
BenchmarkTools.Trial: 10000 samples with 1000 evaluations.
 Range (min … max):  1.397 ns … 33.455 ns  ┊ GC (min … max): 0.00% … 0.00%
 Time  (median):     4.819 ns              ┊ GC (median):    0.00%
 Time  (mean ± σ):   4.907 ns ±  1.042 ns  ┊ GC (mean ± σ):  0.00% ± 0.00%

                                               ██    ▅▅
  ▂▁▁▁▁▂▂▂▁▁▁▁▂▃▂▁▁▁▁▂▂▁▁▁▂▃▃▂▁▁▁▂▂▂▁▁▁▁▂▂▂▁▁▃███▆▁▂▄███▃▁▂▂ ▃
  1.4 ns         Histogram: frequency by time        5.66 ns <

 Memory estimate: 0 bytes, allocs estimate: 0.
```
@codecov
Copy link

codecov bot commented May 21, 2022

Codecov Report

Merging #5 (5151994) into master (6bd82b3) will increase coverage by 0.02%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master       #5      +/-   ##
==========================================
+ Coverage   97.05%   97.08%   +0.02%     
==========================================
  Files           1        1              
  Lines         136      137       +1     
==========================================
+ Hits          132      133       +1     
  Misses          4        4              
Impacted Files Coverage Δ
src/BitFlags.jl 97.08% <100.00%> (+0.02%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6bd82b3...5151994. Read the comment docs.

@jmert jmert merged commit 9baf867 into master May 21, 2022
@jmert jmert deleted the hashfunc branch May 21, 2022 15:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant