cord_analysis.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. // Copyright 2021 The Abseil Authors
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // https://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. #ifndef ABSL_STRINGS_CORD_ANALYSIS_H_
  15. #define ABSL_STRINGS_CORD_ANALYSIS_H_
  16. #include <cstddef>
  17. #include <cstdint>
  18. #include "absl/base/config.h"
  19. #include "absl/strings/internal/cord_internal.h"
  20. namespace absl {
  21. ABSL_NAMESPACE_BEGIN
  22. namespace cord_internal {
  23. // Returns the *approximate* number of bytes held in full or in part by this
  24. // Cord (which may not remain the same between invocations). Cords that share
  25. // memory could each be "charged" independently for the same shared memory.
  26. size_t GetEstimatedMemoryUsage(const CordRep* rep);
  27. // Returns the *approximate* number of bytes held in full or in part by this
  28. // CordRep weighted by the sharing ratio of that data. For example, if some data
  29. // edge is shared by 4 different Cords, then each cord is attribute 1/4th of
  30. // the total memory usage as a 'fair share' of the total memory usage.
  31. size_t GetEstimatedFairShareMemoryUsage(const CordRep* rep);
  32. } // namespace cord_internal
  33. ABSL_NAMESPACE_END
  34. } // namespace absl
  35. #endif // ABSL_STRINGS_CORD_ANALYSIS_H_