New answers tagged .net
1
vote
Thread-safe int wrapper in c#
// read freshest value
private int Get() => Interlocked.CompareExchange(ref _value, 0, 0);
Using an ...
2
votes
Accepted
Thread-safe int wrapper in c#
Based on the discussion in the comments section I think the code can be greatly simplified:
...
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 ...
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 ...
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 <...
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 ...
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...
Top 50 recent answers are included
Related Tags
.net × 1238c# × 1135
performance × 96
vb.net × 71
multithreading × 61
object-oriented × 59
linq × 58
design-patterns × 53
asp.net × 45
winforms × 44
algorithm × 41
strings × 38
beginner × 37
wpf × 36
entity-framework × 34
asynchronous × 30
generics × 30
thread-safety × 30
async-await × 30
reflection × 27
security × 26
mvp × 26
sql × 24
cryptography × 24
game × 22