New answers tagged

1 vote

Simple .NET Web App for managing family budget

I personally do not feel it violates SRP by editing and deleting budgets. I would expect a budget manager to be able to perform both of those things, as well as delete budgets. What I do take ...
Rick Davin's user avatar
  • 6,227
2 votes

LinearUpscale2DArrayInPlace in Unity Jobs

Yay, a performance question that comes with profiler measurements! Excellent. function call overhead Thank you for those three tiny helper functions, they do a good job of explaining what's going on. ...
J_H's user avatar
  • 16.8k
1 vote

Thread-safe int wrapper in c#

// read freshest value private int Get() => Interlocked.CompareExchange(ref _value, 0, 0); Using an ...
harold's user avatar
  • 9,059
3 votes
Accepted

Thread-safe int wrapper in c#

Based on the discussion in the comments section I think the code can be greatly simplified: ...
Peter Csala's user avatar
  • 8,520
3 votes

Implementation of aes-cbc-hmac combined with xchacha20-poly1305

threat environment [I appended some material in this vein at end-of-answer.] Apparently you're addressing a use case along these lines: Alice has sensitive material to store or transmit Mallory wants ...
J_H's user avatar
  • 16.8k
1 vote

Builiding a Model from Stored Procedures

You are committing the same "code smell" sin with public abstract class ReportBase. All properties and no functionality. The ...
radarbob's user avatar
  • 7,294
2 votes

Builiding a Model from Stored Procedures

We commonly do it with "Meta-Information" hardcoded in the form of attributes. This allows to derive all "Datamodels" from a baseclass, which then implements the databse interface ...
ElectronicsStudent's user avatar
1 vote
Accepted

My Drawing Finder

informative identifier namespace Finder Maybe a bit on the vague side? Consider DrawingFinder or even ...
J_H's user avatar
  • 16.8k
1 vote

Optimisation: Fastest way to multiply every number in an array by 2

Thanks to @harold the goal of getting under 50 ns was achieved with loop unrolling and removing the unnecessary copy instruction. The code below is similar to his but is bithacked and instead of using ...
Henners2002's user avatar
1 vote

Optimisation: Fastest way to multiply every number in an array by 2

A couple of further things we can do are: Use Vector256.StoreUnsafe for the store. It's not a huge deal, but going by the assembly, the ...
harold's user avatar
  • 9,059
0 votes
Accepted

How to optimize the player movement code like in Tomb Of The Musk game?

In terms of performance what I have done is removed unnecessary method calls and helped out your branch predictor by removing if/else statements. What I have mainly done though is to enhance code ...
Henners2002's user avatar
1 vote

Optimisation: Fastest way to multiply every number in an array by 2

After a suggestion by @harold a further 15ns has been shaved off by using the Vector.ShiftLeft(v, 1) method instead of doing the multiplication and secondly to use <...
Henners2002's user avatar
1 vote

Optimisation: Fastest way to multiply every number in an array by 2

Upon a suggestion from @iSR5 I have reimplemented the SIMD instruction using the MemoryMarshall method. This has shaved off a further 60ns. I think SIMD instructions and the memory marshall method go ...
Henners2002's user avatar
3 votes

Optimisation: Fastest way to multiply every number in an array by 2

I have shaved off about 100ns with the following improvements: used a shift operator to perform the multiplication by 2, since I know that my Vector<int>.Count...
Henners2002's user avatar
0 votes

Thread safe accessing memory cache using semaphore

One thing that I found out the hard way. Waiting for semaphore entry should be outside the try-catch statement. In original code, when a thread awaits for semaphore entry and a cancellation token is ...
Prolog's user avatar
  • 263

Top 50 recent answers are included