DictionaryStats.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. //-------------------------------------------------------------------------------------------------------
  2. // Copyright (C) Microsoft. All rights reserved.
  3. // Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
  4. //-------------------------------------------------------------------------------------------------------
  5. #pragma once
  6. #if PROFILE_DICTIONARY
  7. class DictionaryStats;
  8. struct DictionaryType
  9. {
  10. int instancesCount;
  11. DictionaryType* pNext;
  12. char name[256];
  13. DictionaryStats* instances;
  14. };
  15. class DictionaryStats
  16. {
  17. public:
  18. static DictionaryStats* Create(const char* name, uint initialSize);
  19. static void OutputStats();
  20. private:
  21. static void ComputeStats(uint input, double &total, double &max);
  22. static void ComputeStats(double input, double &total, double &max);
  23. static void ClearStats();
  24. static DictionaryType* dictionaryTypes;
  25. static CRITICAL_SECTION dictionaryTypesCriticalSection;
  26. public:
  27. void Resize(uint newSize, uint emptyBucketCount);
  28. void Insert(uint depth);
  29. void Remove(bool isBucketEmpty);
  30. void Lookup(uint depth);
  31. DictionaryStats* Clone();
  32. DictionaryStats* pNext;
  33. private:
  34. DictionaryStats(const char* name, uint initialSize);
  35. uint initialSize;
  36. uint finalSize;
  37. uint countOfEmptyBuckets;
  38. uint countOfResize;
  39. uint itemCount;
  40. uint maxDepth;
  41. uint lookupCount;
  42. uint collisionCount;
  43. uint lookupDepthTotal;
  44. uint maxLookupDepth;
  45. char* pName;
  46. };
  47. #endif