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 15 #ifndef ABSL_STRINGS_CORD_ANALYSIS_H_ 16 #define ABSL_STRINGS_CORD_ANALYSIS_H_ 17 18 #include <cstddef> 19 #include <cstdint> 20 21 #include "absl/base/config.h" 22 #include "absl/strings/internal/cord_internal.h" 23 24 namespace absl { 25 ABSL_NAMESPACE_BEGIN 26 namespace cord_internal { 27 28 // Returns the *approximate* number of bytes held in full or in part by this 29 // Cord (which may not remain the same between invocations). Cords that share 30 // memory could each be "charged" independently for the same shared memory. 31 size_t GetEstimatedMemoryUsage(const CordRep* rep); 32 33 // Returns the *approximate* number of bytes held in full or in part by this 34 // CordRep weighted by the sharing ratio of that data. For example, if some data 35 // edge is shared by 4 different Cords, then each cord is attribute 1/4th of 36 // the total memory usage as a 'fair share' of the total memory usage. 37 size_t GetEstimatedFairShareMemoryUsage(const CordRep* rep); 38 39 } // namespace cord_internal 40 ABSL_NAMESPACE_END 41 } // namespace absl 42 43 44 #endif // ABSL_STRINGS_CORD_ANALYSIS_H_ 45