While rewriting Permissions class (with Allow/Deny/Inherit flags), i did some performance testing on different implementations:
  • 3 sets of enum flags encapsulated in a class
  • 3 sets of enum flags encapsulated in a struct
  • Dictionary implementation (Dictionary<PermissionsItem, AllowType>)

Here are test results:

Performance (using simple timers):
  • There's no performance difference between using struct instead of class
  • Indexer: at least 5 time faster than using Dictionaries
  • ToString: class implementation provided fastest results. Structs and dictionaries were about the same (1.5 times slower)
  • Construction overhead of Dictionaries* was much higher than other implementations (200ms for 10000 objects)

Memory usage (testing on 10,000 objects):
  • Structs were most memory efficient - 120KB
  • Class implementation is next in line - 320KB (roughtly 2.5 time more than structures)
  • Dictionary implementation has shown shocking results - 6,640KB (55 times more than structures).

And the winner is: class implementation.