Skip to content

Instantly share code, notes, and snippets.

// Intel(R) Core(TM) i7-2600 CPU @ 3.40 GHz 3.40 GHz
// 16 GB RAM, Windows 7, 64 bit
//
// cl 19
// /GS /GL /W3 /Gy /Zc:wchar_t /Zi /Gm- /O2 /Zc:inline /fp:precise /D "NDEBUG" /D "_CONSOLE" /D "_UNICODE" /D "UNICODE" /WX- /Zc:forScope /Gd /Oi /MD /EHsc /nologo /Ot
//
// 1000 random vectors with 1 000 000 elements each.
// 11 tests: with 0%, 10%, 20%, ..., 90%, 100% duplicates in vectors.
// Ratio: 0
@bartoszkp
bartoszkp / EnumGetValuesTest.cs
Last active August 18, 2022 13:16
Enum.GetValues: cast vs. no cast to typed array test.
// Intel(R) Core(TM) i7-2600 CPU @ 3.40 GHz 3.40 GHz
// 16 GB RAM, Windows 7, 64 bit
//
//No cast:0.854751600000001 +- 0.182965645566156ms
//Cast:0.724137 +- 0.148216330378943ms
// Conclusion: Cast is indeed faster, but remember that we are talking here about _miliseconds_
// for 1000 enumerations of an enum with 1000 elements. First verify whether this is really significant in your code, before
// proceeding with micro-optimizations.
// Context: http://stackoverflow.com/a/105402/2642204