BHoM / BHoM/BHoM_Engine

BHoM_Engine: Consider refactoring `Query.Hash`'s `HashString()` method with byRef StringBuilder for performance

Open
#2,931 0 comments 0 reactions 1 assignee Claimed by @alelom View on GitHub
type:feature
Dominant language
C#
Stars
30
Forks
13
Avg merge
7d 10h
Merged PRs (30d)
5

Description

#### Description:

Currently we concatenate strings in `HashString()`:
https://github.com/BHoM/BHoM_Engine/blob/main/BHoM_Engine/Query/Hash.cs#L119

[Preliminary profling](https://github.com/BHoM/DiffingTests_Prototypes/commit/46ef40967e355fdc902e27b241cd99c4219db2de) on a [prototype refactoring](https://github.com/BHoM/BHoM_Engine/commit/35fea6b374d19a109212ebc9fb46ea7245480fda) with a `StringBuilder` passed in the arguments, the result shows a reduction of about 30% in the hashing time.

Hashing for 10000 random objects of type `Bar` and `NurbsCurve` (5000+5000):
- currently: [about 2300ms](https://user-images.githubusercontent.com/6352844/197259503-11ff103b-b76f-4b67-b754-d78fa42bcb5e.png)
- with StringBuilder: [about 1700ms](https://user-images.githubusercontent.com/6352844/197258994-f2e91bac-38b7-4bf0-b859-e15806fca2a2.png)

@IsakNaslundBh FYI

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.