├── .editorconfig
├── .gitattributes
├── .github
├── FUNDING.yml
├── ISSUE_TEMPLATE
│ ├── bug_report.md
│ └── feature_request.md
└── workflows
│ ├── generic-build.yml
│ └── nuget-release.yml
├── .gitignore
├── .globalconfig
├── FastHash.sln
├── FastHash.sln.DotSettings
├── Imports
├── Benchmarks.props
├── Console.props
├── Examples.props
├── Library.props
└── Tests.props
├── LICENSE.txt
├── Locals
├── Directory.Build.props
└── Directory.Packages.props
├── README.md
└── Src
├── Directory.Build.props
├── Directory.Build.targets
├── Directory.Packages.Analyzers.props
├── Directory.Packages.props
├── FastHash.Benchmarks
├── Code
│ ├── BenchmarkHelper.cs
│ ├── MbPrSecColumn.cs
│ └── MbPrSecColumnAttribute.cs
├── FastHash.Benchmarks.csproj
├── HashBenchmarks.cs
├── Index32Benchmarks.cs
├── Index64Benchmarks.cs
├── MixerBenchmarks.cs
├── Multiply64Benchmarks.cs
├── Program.cs
├── ReadAlignedBenchmarks.cs
└── ReadUnalignedBenchmarks.cs
├── FastHash.Examples
├── FastHash.Examples.csproj
└── Program.cs
├── FastHash.TestShared
├── FastHash.TestShared.csproj
├── MixSpec32.cs
├── MixSpec64.cs
└── Mult.cs
├── FastHash.Tests
├── FastHash.Tests.csproj
├── GeneralTests.cs
├── HashTests.cs
├── IndexTests.cs
├── MixerTests.cs
├── MultTests.cs
└── Single
│ ├── CityHashTests.cs
│ ├── DjbHashTests.cs
│ ├── FarmHashTests.cs
│ ├── FarshHashTests.cs
│ ├── FnvHashTests.cs
│ ├── GxHashTests.cs
│ ├── HighwayHashTests.cs
│ ├── PolymurHashTests.cs
│ ├── SipHashTests.cs
│ ├── WyHashTests.cs
│ ├── Xx2HashTests.cs
│ └── Xx3HashTests.cs
└── FastHash
├── AesniHash
├── AesniHash128.cs
└── AesniHash64.cs
├── CityHash
├── CityHash128.cs
├── CityHash128Unsafe.cs
├── CityHash32.cs
├── CityHash32Unsafe.cs
├── CityHash64.cs
├── CityHash64Unsafe.cs
├── CityHashConstants.cs
├── CityHashShared.cs
└── CityHashUnsafeShared.cs
├── DjbHash
├── Djb2Hash32.cs
├── Djb2Hash32Unsafe.cs
├── Djb2Hash64.cs
├── Djb2Hash64Unsafe.cs
└── DjbHashConstants.cs
├── FarmHash
├── FarmHash32.cs
├── FarmHash32Unsafe.cs
├── FarmHash64.cs
├── FarmHash64Unsafe.cs
└── FarmHashConstants.cs
├── FarshHash
├── FarshHash64.cs
├── FarshHash64Unsafe.cs
└── FarshHashConstants.cs
├── FastHash.csproj
├── FnvHash
├── Fnv1aHash32.cs
├── Fnv1aHash32Unsafe.cs
├── Fnv1aHash64.cs
├── Fnv1aHash64Unsafe.cs
└── FnvHashConstants.cs
├── GxHash
├── GxHash128.cs
├── GxHash32.cs
├── GxHash64.cs
└── GxHashShared.cs
├── HighwayHash
├── HighwayHash64Unsafe.cs
├── HighwayHashConstants.cs
└── HighwayHashState.cs
├── MarvinHash
├── MarvinHash32.cs
└── MarvinHash64.cs
├── MeowHash
├── MeowHash128Unsafe.cs
└── MeowHash64Unsafe.cs
├── Misc
├── IsExternalInit.cs
└── Utilities.cs
├── MixFunctions.cs
├── MurmurHash
├── Murmur3Hash128.cs
├── Murmur3Hash128Unsafe.cs
├── Murmur3Hash32.cs
├── Murmur3Hash32Unsafe.cs
└── MurmurHashConstants.cs
├── PolymurHash
├── Polymur2Hash64.cs
└── PolymurConstants.cs
├── Properties
└── GlobalUsings.cs
├── SipHash
├── SipHash64.cs
├── SipHash64Unsafe.cs
└── SipHashConstants.cs
├── SuperFastHash
├── SuperFastHash32.cs
└── SuperFastHash32Unsafe.cs
├── UInt128.cs
├── WyHash
├── Wy3Hash64.cs
├── Wy3Hash64Unsafe.cs
└── WyHashConstants.cs
└── XxHash
├── Xx2Hash32.cs
├── Xx2Hash32Unsafe.cs
├── Xx2Hash64.cs
├── Xx2Hash64Unsafe.cs
├── Xx3Hash128.cs
├── Xx3Hash128Unsafe.cs
├── Xx3Hash64.cs
├── Xx3Hash64Unsafe.cs
├── XxHashConstants.cs
├── XxHashShared.cs
└── XxHashUnsafeShared.cs
/.editorconfig:
--------------------------------------------------------------------------------
1 | root = true
2 |
3 | [*]
4 | charset = utf-8
5 | trim_trailing_whitespace = true
6 | insert_final_newline = false
7 | max_line_length = 180
8 |
9 | # XML based formats
10 | [*.{appxmanifest,axml,build,config,csproj,dbml,discomap,dtd,jsproj,lsproj,njsproj,nuspec,proj,props,resw,resx,StyleCop,targets,tasks,vbproj,xml,xsd}]
11 | indent_style = space
12 | indent_size = 2
13 | tab_width = 2
14 | ij_xml_space_inside_empty_tag = true
15 | ij_xml_keep_blank_lines = 1
16 |
17 | # JSON based formats
18 | [*.{json,resjson}]
19 | indent_style = space
20 | indent_size = 2
21 | tab_width = 2
22 |
23 | # Web languages
24 | [*.{css,htm,html,js}]
25 | indent_style = space
26 | indent_size = 2
27 | tab_width = 2
28 |
29 | # Programming languages
30 | [*.{asax,ascx,aspx,axaml,cs,cshtml}]
31 | indent_style = space
32 | indent_size = 4
33 | tab_width = 4
34 |
35 | # Analyzer settings
36 | roslynator_accessibility_modifiers = explicit
37 | roslynator_enum_has_flag_style = method
38 | roslynator_object_creation_type_style = explicit
39 | roslynator_use_var_instead_of_implicit_object_creation = false
40 | csharp_style_namespace_declarations = file_scoped:error
41 | dotnet_public_api_analyzer.require_api_files = true # Disable the requirement for projects to have a PublicAPI.Shipped.txt file
42 |
43 | # Csharp styles
44 | csharp_new_line_before_members_in_object_initializers = false
45 | csharp_preferred_modifier_order = public, private, protected, internal, new, sealed, static, unsafe, override, extern, async, virtual, abstract, volatile, readonly:suggestion
46 | csharp_preserve_single_line_blocks = true
47 | csharp_space_after_cast = false
48 | csharp_style_var_elsewhere = false:none
49 | csharp_style_var_when_type_is_apparent = false:none
50 |
51 | # ReSharper properties
52 | resharper_align_multiline_calls_chain = true
53 | resharper_arguments_skip_single = true
54 | resharper_blank_lines_after_block_statements = 0
55 | resharper_blank_lines_after_start_comment = 0
56 | resharper_blank_lines_around_auto_property = 1
57 | resharper_blank_lines_around_property = 1
58 | resharper_blank_lines_around_single_line_type = 0
59 | resharper_braces_for_fixed = required_for_multiline
60 | resharper_braces_for_for = required_for_multiline
61 | resharper_braces_for_foreach = required_for_multiline
62 | resharper_braces_for_ifelse = required_for_multiline
63 | resharper_braces_for_lock = required_for_multiline
64 | resharper_braces_for_using = required_for_multiline
65 | resharper_braces_for_while = required_for_multiline
66 | resharper_csharp_blank_lines_around_field = 0
67 | resharper_csharp_blank_lines_around_invocable = 1
68 | resharper_csharp_empty_block_style = together_same_line
69 | resharper_csharp_keep_blank_lines_in_code = 1
70 | resharper_csharp_keep_blank_lines_in_declarations = 1
71 | resharper_csharp_max_line_length = 2081
72 | resharper_csharp_space_before_trailing_comment = true
73 | resharper_csharp_wrap_lines = false
74 | resharper_csharp_wrap_parameters_style = chop_if_long
75 | resharper_indent_preprocessor_other = do_not_change
76 | resharper_instance_members_qualify_declared_in = this_class
77 | resharper_keep_existing_attribute_arrangement = true
78 | resharper_keep_existing_enum_arrangement = false
79 | resharper_local_function_body = expression_body
80 | resharper_method_or_operator_body = expression_body
81 | resharper_nested_ternary_style = compact
82 | resharper_object_creation_when_type_evident = explicitly_typed
83 | resharper_place_accessorholder_attribute_on_same_line = false
84 | resharper_place_accessor_attribute_on_same_line = true
85 | resharper_place_expr_accessor_on_single_line = true
86 | resharper_place_expr_method_on_single_line = true
87 | resharper_place_expr_property_on_single_line = true
88 | resharper_place_field_attribute_on_same_line = false
89 | resharper_place_simple_embedded_statement_on_same_line = false
90 | resharper_place_simple_initializer_on_single_line = true
91 | resharper_remove_blank_lines_near_braces_in_code = true
92 | resharper_remove_blank_lines_near_braces_in_declarations = true
93 | resharper_space_after_attributes = false
94 | resharper_space_between_attribute_sections = false
95 | resharper_space_within_empty_braces = false
96 | resharper_space_within_single_line_array_initializer_braces = true
97 | resharper_wrap_object_and_collection_initializer_style = chop_always
98 | resharper_space_before_trailing_comment = true
99 | resharper_xmldoc_indent_text = ZeroIndent
100 | resharper_xmldoc_max_line_length = 300
101 | resharper_xmldoc_attribute_indent = align_by_first_attribute
102 | resharper_xmldoc_keep_user_linebreaks = true
103 | resharper_parentheses_non_obvious_operations = none, multiplicative, additive, arithmetic, shift, bitwise_and, bitwise_exclusive_or, bitwise_inclusive_or, bitwise
104 |
105 | # Microsoft .NET properties
106 | csharp_style_var_for_built_in_types = false:suggestion
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Linux scripts
2 | *.sh text eol=lf
3 | *.py text diff=python eol=lf
4 |
5 | # Linux configs
6 | *.conf text eol=lf
7 | *.yml text eol=lf
8 |
9 | # Windows scripts
10 | *.ps1 text eol=crlf
11 | *.cmd text eol=crlf
12 | *.bat text eol=crlf
13 |
14 | # Source code files
15 | *.cs text diff=csharp
16 | *.cshtml text
17 | *.json text
18 | *.xml text
19 | *.html text diff=html
20 | *.css text diff=css
21 | *.scss text diff=css
22 | *.js text
23 | *.csproj text
24 | *.targets text ident
25 | *.sln text
26 |
27 | # Images
28 | *.svg text
29 |
30 | # Text files
31 | *.txt text
32 | *.md text
33 | *.markdowm text
34 |
35 | ###############################
36 | # Git Large File System (LFS) #
37 | ###############################
38 |
39 | # Archives
40 | *.7z filter=lfs diff=lfs merge=lfs -text
41 | *.rar filter=lfs diff=lfs merge=lfs -text
42 | *.br filter=lfs diff=lfs merge=lfs -text
43 | *.gz filter=lfs diff=lfs merge=lfs -text
44 | *.tar filter=lfs diff=lfs merge=lfs -text
45 | *.zip filter=lfs diff=lfs merge=lfs -text
46 |
47 | # Documents
48 | *.pdf filter=lfs diff=lfs merge=lfs -text
49 | *.doc filter=lfs diff=lfs merge=lfs -text
50 | *.docx filter=lfs diff=lfs merge=lfs -text
51 |
52 | # Images
53 | *.gif filter=lfs diff=lfs merge=lfs -text
54 | *.ico filter=lfs diff=lfs merge=lfs -text
55 | *.jpg filter=lfs diff=lfs merge=lfs -text
56 | *.png filter=lfs diff=lfs merge=lfs -text
57 | *.psd filter=lfs diff=lfs merge=lfs -text
58 | *.webp filter=lfs diff=lfs merge=lfs -text
59 | *.bmp filter=lfs diff=lfs merge=lfs -text
60 |
61 | # Fonts
62 | *.woff2 filter=lfs diff=lfs merge=lfs -text
63 |
64 | # Other
65 | *.exe filter=lfs diff=lfs merge=lfs -text
--------------------------------------------------------------------------------
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | github: [Genbox]
2 | custom: http://paypal.me/IanQvist
3 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/bug_report.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Bug report
3 | about: Report a bug
4 | title: ''
5 | labels: bug
6 | assignees: ''
7 |
8 | ---
9 |
10 | * [ ] I hereby verify that I am a sponsor.
11 |
12 | Sponsorship is required before you can submit bug reports. See https://github.com/sponsors/Genbox
13 |
14 | **Describe the bug**
15 | What is the bug about?
16 |
17 | **How to reproduce?**
18 | Describe steps to reproduce the bug. Please include code to reproduce if possible.
19 |
20 | **Expected behavior**
21 | Describe what you expected to happen.
22 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/feature_request.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Feature request
3 | about: Suggest a feature for this project
4 | title: ''
5 | labels: enhancement
6 | assignees: ''
7 |
8 | ---
9 |
10 | * [ ] I hereby verify that I am a sponsor.
11 |
12 | Sponsorship is required before you can submit feature requests. See https://github.com/sponsors/Genbox
13 |
14 | **Describe the feature**
15 | Provide a short description of the feature. Why would you like the feature?
16 | If the feature makes changes to an existing or new API please provide an example.
17 |
--------------------------------------------------------------------------------
/.github/workflows/generic-build.yml:
--------------------------------------------------------------------------------
1 | name: Generic build
2 |
3 | on:
4 | push:
5 | branches:
6 | - 'master'
7 | tags-ignore:
8 | - '**'
9 |
10 | env:
11 | DOTNET_EnableDiagnostics: 0
12 | DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
13 | DOTNET_NOLOGO: true
14 | DOTNET_CLI_TELEMETRY_OPTOUT: true
15 | DOTNET_GENERATE_ASPNET_CERTIFICATE: false
16 |
17 | jobs:
18 | build:
19 | runs-on: ubuntu-latest
20 |
21 | steps:
22 | - uses: actions/checkout@v3
23 | - name: Setup .NET Core 7.0
24 | uses: actions/setup-dotnet@v3
25 | with:
26 | dotnet-version: '7.0.x'
27 | - name: Build
28 | run: dotnet build -c Release FastHash.sln
--------------------------------------------------------------------------------
/.github/workflows/nuget-release.yml:
--------------------------------------------------------------------------------
1 | name: Nuget release
2 |
3 | on:
4 | push:
5 | tags:
6 | - '[0-9]+.[0-9]+.[0-9]+**'
7 |
8 | env:
9 | DOTNET_EnableDiagnostics: 0
10 | DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
11 | DOTNET_NOLOGO: true
12 | DOTNET_CLI_TELEMETRY_OPTOUT: true
13 | DOTNET_GENERATE_ASPNET_CERTIFICATE: false
14 |
15 | jobs:
16 | build:
17 | runs-on: ubuntu-latest
18 |
19 | steps:
20 | - uses: actions/checkout@v3
21 | - name: Setup .NET Core 7.0
22 | uses: actions/setup-dotnet@v3
23 | with:
24 | dotnet-version: '7.0.x'
25 | - name: Pack release
26 | run: dotnet pack -c Release -o tmp FastHash.sln
27 | - name: Upload to nuget
28 | run: dotnet nuget push --skip-duplicate -k ${{secrets.NUGET_KEY}} -s https://api.nuget.org/v3/index.json tmp/*
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Build results
2 | [Bb]in/
3 | [Oo]bj/
4 | [Ll]og/
5 |
6 | # NuGet Packages
7 | *.nupkg
8 | *.snupkg
9 |
10 | # Others
11 | *.pfx
12 | *.publishsettings
13 |
14 | # SQL Server files
15 | *.mdf
16 | *.ldf
17 | *.ndf
18 |
19 | # Visual Studio cache folder
20 | .vs/
21 |
22 | # Rider cache folder
23 | .idea/
24 | *.sln.DotSettings.user
25 |
26 | # Benchmark.Net artifact folder
27 | *BenchmarkDotNet.Artifacts/
--------------------------------------------------------------------------------
/FastHash.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 17
4 | VisualStudioVersion = 17.0.32112.339
5 | MinimumVisualStudioVersion = 15.0.26124.0
6 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "_Items", "_Items", "{EF1D19B3-97F1-4504-95AB-BE249F5BF29A}"
7 | ProjectSection(SolutionItems) = preProject
8 | .gitattributes = .gitattributes
9 | .gitignore = .gitignore
10 | LICENSE.txt = LICENSE.txt
11 | README.md = README.md
12 | EndProjectSection
13 | EndProject
14 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "_Imports", "_Imports", "{C17720CD-1FBA-4181-A15D-5E361643B534}"
15 | EndProject
16 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "_Github", "_Github", "{9301EE8C-BC1F-4169-A4F6-629E904E1AFB}"
17 | ProjectSection(SolutionItems) = preProject
18 | .github\FUNDING.yml = .github\FUNDING.yml
19 | EndProjectSection
20 | EndProject
21 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "IssueTemplates", "IssueTemplates", "{3DF56598-0F2D-4D4A-B4A9-18C1CAA0D6B0}"
22 | ProjectSection(SolutionItems) = preProject
23 | .github\ISSUE_TEMPLATE\bug_report.md = .github\ISSUE_TEMPLATE\bug_report.md
24 | .github\ISSUE_TEMPLATE\feature_request.md = .github\ISSUE_TEMPLATE\feature_request.md
25 | EndProjectSection
26 | EndProject
27 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Workflows", "Workflows", "{01EB71A8-87A4-410E-9AC9-8C0F0F6EA7BB}"
28 | ProjectSection(SolutionItems) = preProject
29 | .github\workflows\generic-build.yml = .github\workflows\generic-build.yml
30 | .github\workflows\nuget-release.yml = .github\workflows\nuget-release.yml
31 | EndProjectSection
32 | EndProject
33 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Local", "Local", "{008D0251-18C2-4B29-99BB-718EF8E7DC85}"
34 | ProjectSection(SolutionItems) = preProject
35 | Locals\Directory.Build.props = Locals\Directory.Build.props
36 | Locals\Directory.Packages.props = Locals\Directory.Packages.props
37 | EndProjectSection
38 | EndProject
39 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Managed", "Managed", "{A112EE96-0FDF-460B-9F35-F4A8608DE4CD}"
40 | ProjectSection(SolutionItems) = preProject
41 | Src\Directory.Build.targets = Src\Directory.Build.targets
42 | Src\Directory.Build.props = Src\Directory.Build.props
43 | EndProjectSection
44 | EndProject
45 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Packages", "Packages", "{28F1C9B8-268B-46C3-97B4-73CB90CD9E2A}"
46 | ProjectSection(SolutionItems) = preProject
47 | Src\Directory.Packages.props = Src\Directory.Packages.props
48 | Src\Directory.Packages.Analyzers.props = Src\Directory.Packages.Analyzers.props
49 | EndProjectSection
50 | EndProject
51 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Project", "Project", "{6A21A9F3-0DB5-48D1-9097-E2A327734844}"
52 | ProjectSection(SolutionItems) = preProject
53 | Imports\Benchmarks.props = Imports\Benchmarks.props
54 | Imports\Examples.props = Imports\Examples.props
55 | Imports\Library.props = Imports\Library.props
56 | Imports\Tests.props = Imports\Tests.props
57 | EndProjectSection
58 | EndProject
59 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FastHash", "Src\FastHash\FastHash.csproj", "{A74CB252-3544-40BD-A166-15A25B07B856}"
60 | EndProject
61 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FastHash.Benchmarks", "Src\FastHash.Benchmarks\FastHash.Benchmarks.csproj", "{6AF9A9F2-68DE-4FC8-A7EF-60AD142D594A}"
62 | EndProject
63 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FastHash.Tests", "Src\FastHash.Tests\FastHash.Tests.csproj", "{54D07448-1E1E-4292-A39A-E1676607C662}"
64 | EndProject
65 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FastHash.TestShared", "Src\FastHash.TestShared\FastHash.TestShared.csproj", "{9443A0FE-29C8-47D1-B015-A630DA5B4D5F}"
66 | EndProject
67 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FastHash.Examples", "Src\FastHash.Examples\FastHash.Examples.csproj", "{F0B90C1B-9455-4078-BAD9-B77A83CDAE18}"
68 | EndProject
69 | Global
70 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
71 | Debug|Any CPU = Debug|Any CPU
72 | Release|Any CPU = Release|Any CPU
73 | EndGlobalSection
74 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
75 | {A74CB252-3544-40BD-A166-15A25B07B856}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
76 | {A74CB252-3544-40BD-A166-15A25B07B856}.Debug|Any CPU.Build.0 = Debug|Any CPU
77 | {A74CB252-3544-40BD-A166-15A25B07B856}.Release|Any CPU.ActiveCfg = Release|Any CPU
78 | {A74CB252-3544-40BD-A166-15A25B07B856}.Release|Any CPU.Build.0 = Release|Any CPU
79 | {6AF9A9F2-68DE-4FC8-A7EF-60AD142D594A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
80 | {6AF9A9F2-68DE-4FC8-A7EF-60AD142D594A}.Debug|Any CPU.Build.0 = Debug|Any CPU
81 | {6AF9A9F2-68DE-4FC8-A7EF-60AD142D594A}.Release|Any CPU.ActiveCfg = Release|Any CPU
82 | {6AF9A9F2-68DE-4FC8-A7EF-60AD142D594A}.Release|Any CPU.Build.0 = Release|Any CPU
83 | {54D07448-1E1E-4292-A39A-E1676607C662}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
84 | {54D07448-1E1E-4292-A39A-E1676607C662}.Debug|Any CPU.Build.0 = Debug|Any CPU
85 | {54D07448-1E1E-4292-A39A-E1676607C662}.Release|Any CPU.ActiveCfg = Release|Any CPU
86 | {54D07448-1E1E-4292-A39A-E1676607C662}.Release|Any CPU.Build.0 = Release|Any CPU
87 | {9443A0FE-29C8-47D1-B015-A630DA5B4D5F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
88 | {9443A0FE-29C8-47D1-B015-A630DA5B4D5F}.Debug|Any CPU.Build.0 = Debug|Any CPU
89 | {9443A0FE-29C8-47D1-B015-A630DA5B4D5F}.Release|Any CPU.ActiveCfg = Release|Any CPU
90 | {9443A0FE-29C8-47D1-B015-A630DA5B4D5F}.Release|Any CPU.Build.0 = Release|Any CPU
91 | {F0B90C1B-9455-4078-BAD9-B77A83CDAE18}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
92 | {F0B90C1B-9455-4078-BAD9-B77A83CDAE18}.Debug|Any CPU.Build.0 = Debug|Any CPU
93 | {F0B90C1B-9455-4078-BAD9-B77A83CDAE18}.Release|Any CPU.ActiveCfg = Release|Any CPU
94 | {F0B90C1B-9455-4078-BAD9-B77A83CDAE18}.Release|Any CPU.Build.0 = Release|Any CPU
95 | EndGlobalSection
96 | GlobalSection(SolutionProperties) = preSolution
97 | HideSolutionNode = FALSE
98 | EndGlobalSection
99 | GlobalSection(ExtensibilityGlobals) = postSolution
100 | SolutionGuid = {A9354605-C154-495A-B990-F6AB329CDE39}
101 | EndGlobalSection
102 | GlobalSection(NestedProjects) = preSolution
103 | {3DF56598-0F2D-4D4A-B4A9-18C1CAA0D6B0} = {9301EE8C-BC1F-4169-A4F6-629E904E1AFB}
104 | {01EB71A8-87A4-410E-9AC9-8C0F0F6EA7BB} = {9301EE8C-BC1F-4169-A4F6-629E904E1AFB}
105 | {008D0251-18C2-4B29-99BB-718EF8E7DC85} = {C17720CD-1FBA-4181-A15D-5E361643B534}
106 | {A112EE96-0FDF-460B-9F35-F4A8608DE4CD} = {C17720CD-1FBA-4181-A15D-5E361643B534}
107 | {28F1C9B8-268B-46C3-97B4-73CB90CD9E2A} = {A112EE96-0FDF-460B-9F35-F4A8608DE4CD}
108 | {6A21A9F3-0DB5-48D1-9097-E2A327734844} = {A112EE96-0FDF-460B-9F35-F4A8608DE4CD}
109 | EndGlobalSection
110 | EndGlobal
111 |
--------------------------------------------------------------------------------
/FastHash.sln.DotSettings:
--------------------------------------------------------------------------------
1 |
2 | True
3 | True
4 | True
5 | True
6 | True
7 | True
8 | True
9 | True
10 | True
11 | True
12 | True
13 | True
14 | True
15 | True
16 | True
--------------------------------------------------------------------------------
/Imports/Benchmarks.props:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | false
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/Imports/Console.props:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | false
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/Imports/Examples.props:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | false
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/Imports/Library.props:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Library
5 |
6 |
7 |
8 |
9 | <_Parameter1>$(AssemblyName).Tests
10 |
11 |
12 | <_Parameter1>$(AssemblyName).Benchmarks
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
--------------------------------------------------------------------------------
/Imports/Tests.props:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Library
5 | false
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/LICENSE.txt:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2024 Ian Qvist
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/Locals/Directory.Build.props:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | High performance non-cryptographic hash functions
5 | hash non-cryptographic
6 |
7 |
8 |
--------------------------------------------------------------------------------
/Locals/Directory.Packages.props:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/Src/Directory.Build.props:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Ian Qvist
6 | Copyright 2024, by Ian Qvist. All rights reserved.
7 |
8 |
9 |
10 |
11 |
12 | true
13 | true
14 | true
15 |
16 |
17 | Genbox.$(MSBuildProjectName)
18 | Genbox.$(MSBuildProjectName)
19 |
20 |
21 | latest
22 | enable
23 | strict
24 | true
25 | 0
26 |
27 |
28 | true
29 |
30 |
31 | Git
32 | https://github.com/Genbox/$(MSBuildProjectName)
33 | MIT
34 | false
35 |
36 |
37 | $(IncludeAnalyzers)
38 | false
39 | true
40 | all
41 | latest
42 |
43 |
44 | false
45 | true
46 |
47 |
48 | 2
49 | 500
50 | none
51 |
52 |
53 | true
54 | true
55 |
56 |
57 | true
58 | false
59 | true
60 | snupkg
61 |
62 |
63 | true
64 | all
65 | low
66 |
67 |
68 |
69 | true
70 | false
71 |
72 |
73 |
74 |
75 | 5
76 |
77 |
78 |
79 | <_LastDot>$(MSBuildProjectName.LastIndexOf('.', StringComparison.Ordinal))
80 | $(MSBuildProjectName.Substring(0, $(_LastDot)))
81 | $(MSBuildProjectName.Substring($([MSBuild]::Add($(_LastDot), 1))))
82 |
83 |
84 |
85 |
86 |
87 |
--------------------------------------------------------------------------------
/Src/Directory.Build.targets:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 | true
17 | README.md
18 |
19 |
20 |
21 |
22 |
23 |
24 | $(MinVerMajor).$(MinVerMinor).$(MinVerPatch).0
25 |
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/Src/Directory.Packages.Analyzers.props:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/Src/Directory.Packages.props:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/Src/FastHash.Benchmarks/Code/BenchmarkHelper.cs:
--------------------------------------------------------------------------------
1 | namespace Genbox.FastHash.Benchmarks.Code;
2 |
3 | public static class BenchmarkHelper
4 | {
5 | public static byte[] GetRandomBytes(int count)
6 | {
7 | byte[] bytes = GC.AllocateUninitializedArray(count);
8 | Random r = new Random(42);
9 | r.NextBytes(bytes);
10 | return bytes;
11 | }
12 | }
--------------------------------------------------------------------------------
/Src/FastHash.Benchmarks/Code/MbPrSecColumn.cs:
--------------------------------------------------------------------------------
1 | using System.Globalization;
2 | using BenchmarkDotNet.Columns;
3 | using BenchmarkDotNet.Mathematics;
4 | using BenchmarkDotNet.Reports;
5 | using BenchmarkDotNet.Running;
6 |
7 | namespace Genbox.FastHash.Benchmarks.Code;
8 |
9 | public class MbPrSecColumn : IColumn
10 | {
11 | private readonly int _size;
12 |
13 | public MbPrSecColumn(int size = 0)
14 | {
15 | _size = size;
16 | }
17 |
18 | public string Id => nameof(MbPrSecColumn);
19 | public string ColumnName => "MiB/s";
20 |
21 | public string GetValue(Summary summary, BenchmarkCase benchmarkCase)
22 | {
23 | Statistics? stats = summary[benchmarkCase].ResultStatistics;
24 |
25 | if (stats == null)
26 | return "?";
27 |
28 | //Number of operations as determined by the Count parameter
29 |
30 | int size = _size;
31 |
32 | if (size == 0)
33 | size = int.Parse(benchmarkCase.Parameters["Size"].ToString()!, NumberFormatInfo.InvariantInfo);
34 |
35 | //Mean is in nanoseconds, which is 1.000.000.000x less than a second
36 | double time = stats.Mean / 1000 / 1000 / 1000;
37 |
38 | double opsPrSec = (size / 1024f / 1024) / time;
39 | return opsPrSec.ToString("N0", NumberFormatInfo.InvariantInfo);
40 | }
41 |
42 | public bool IsDefault(Summary summary, BenchmarkCase benchmarkCase) => false;
43 | public bool IsAvailable(Summary summary) => true;
44 | public bool AlwaysShow => true;
45 | public ColumnCategory Category => ColumnCategory.Custom;
46 | public bool IsNumeric => true;
47 | public UnitType UnitType => UnitType.Dimensionless;
48 | public string GetValue(Summary summary, BenchmarkCase benchmarkCase, SummaryStyle style) => GetValue(summary, benchmarkCase);
49 | public int PriorityInCategory => 1;
50 | public override string ToString() => ColumnName;
51 | public string Legend => "Mibibytes pr. second";
52 | }
--------------------------------------------------------------------------------
/Src/FastHash.Benchmarks/Code/MbPrSecColumnAttribute.cs:
--------------------------------------------------------------------------------
1 | namespace Genbox.FastHash.Benchmarks.Code;
2 |
3 | [AttributeUsage(AttributeTargets.Class | AttributeTargets.Assembly, AllowMultiple = true)]
4 | public sealed class MbPrSecColumnAttribute : ColumnConfigBaseAttribute
5 | {
6 | public MbPrSecColumnAttribute(int size = 0) : base(new MbPrSecColumn(size)) {}
7 | }
--------------------------------------------------------------------------------
/Src/FastHash.Benchmarks/FastHash.Benchmarks.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net9.0
5 | true
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/Src/FastHash.Benchmarks/Index32Benchmarks.cs:
--------------------------------------------------------------------------------
1 | using BenchmarkDotNet.Order;
2 | using Genbox.FastHash.Benchmarks.Code;
3 | using Genbox.FastHash.CityHash;
4 | using Genbox.FastHash.DjbHash;
5 | using Genbox.FastHash.FarmHash;
6 | using Genbox.FastHash.FnvHash;
7 | using Genbox.FastHash.MarvinHash;
8 | using Genbox.FastHash.MurmurHash;
9 | using Genbox.FastHash.SuperFastHash;
10 | using Genbox.FastHash.XxHash;
11 |
12 | namespace Genbox.FastHash.Benchmarks;
13 |
14 | [MbPrSecColumn(4)]
15 | [Orderer(SummaryOrderPolicy.FastestToSlowest)]
16 | public class Index32Benchmarks
17 | {
18 | private readonly uint _value = 12808241;
19 |
20 | [Benchmark]
21 | public uint CityHash32Test() => CityHash32.ComputeIndex(_value);
22 |
23 | [Benchmark]
24 | public uint Djb2Hash32Test() => Djb2Hash32.ComputeIndex(_value);
25 |
26 | [Benchmark]
27 | public uint FarmHash32Test() => FarmHash32.ComputeIndex(_value);
28 |
29 | [Benchmark]
30 | public uint Fnv1aHash32Test() => Fnv1aHash32.ComputeIndex(_value);
31 |
32 | [Benchmark]
33 | public uint MarvinHash32Test() => MarvinHash32.ComputeIndex(_value);
34 |
35 | [Benchmark]
36 | public uint Murmur3Hash32Test() => Murmur3Hash32.ComputeIndex(_value);
37 |
38 | [Benchmark]
39 | public uint SuperFastHash32Test() => SuperFastHash32.ComputeIndex(_value);
40 |
41 | [Benchmark]
42 | public uint Xx2Hash32Test() => Xx2Hash32.ComputeIndex(_value);
43 | }
--------------------------------------------------------------------------------
/Src/FastHash.Benchmarks/Index64Benchmarks.cs:
--------------------------------------------------------------------------------
1 | using BenchmarkDotNet.Order;
2 | using Genbox.FastHash.Benchmarks.Code;
3 | using Genbox.FastHash.CityHash;
4 | using Genbox.FastHash.DjbHash;
5 | using Genbox.FastHash.FarmHash;
6 | using Genbox.FastHash.FnvHash;
7 | using Genbox.FastHash.PolymurHash;
8 | using Genbox.FastHash.SipHash;
9 | using Genbox.FastHash.WyHash;
10 | using Genbox.FastHash.XxHash;
11 |
12 | namespace Genbox.FastHash.Benchmarks;
13 |
14 | [MbPrSecColumn(8)]
15 | [Orderer(SummaryOrderPolicy.FastestToSlowest)]
16 | public class Index64Benchmarks
17 | {
18 | private readonly ulong _value = 12808224424451380151UL;
19 |
20 | [Benchmark]
21 | public ulong CityHash64Test() => CityHash64.ComputeIndex(_value);
22 |
23 | [Benchmark]
24 | public ulong Djb2Hash64Test() => Djb2Hash64.ComputeIndex(_value);
25 |
26 | [Benchmark]
27 | public ulong FarmHash64Test() => FarmHash64.ComputeIndex(_value);
28 |
29 | [Benchmark]
30 | public ulong Fnv1aHash64Test() => Fnv1aHash64.ComputeIndex(_value);
31 |
32 | [Benchmark]
33 | public ulong Polymur2Hash64Test() => Polymur2Hash64.ComputeIndex(_value);
34 |
35 | [Benchmark]
36 | public ulong SipHash64Test() => SipHash64.ComputeIndex(_value);
37 |
38 | [Benchmark]
39 | public ulong Wy3Hash64Test() => Wy3Hash64.ComputeIndex(_value);
40 |
41 | [Benchmark]
42 | public ulong Xx2Hash64Test() => Xx2Hash64.ComputeIndex(_value);
43 | }
--------------------------------------------------------------------------------
/Src/FastHash.Benchmarks/MixerBenchmarks.cs:
--------------------------------------------------------------------------------
1 | using BenchmarkDotNet.Order;
2 | using Genbox.FastHash.TestShared;
3 | using static Genbox.FastHash.MixFunctions;
4 |
5 | namespace Genbox.FastHash.Benchmarks;
6 |
7 | [Orderer(SummaryOrderPolicy.FastestToSlowest)]
8 | public class MixerBenchmarks
9 | {
10 | [Benchmark]
11 | [ArgumentsSource(nameof(GetMix64))]
12 | public ulong Mix64(MixSpec64 spec) => spec.Func(42);
13 |
14 | [Benchmark]
15 | [ArgumentsSource(nameof(GetMix32))]
16 | public ulong Mix32(MixSpec32 spec) => spec.Func(42);
17 |
18 | public static IEnumerable