FPRFakeConfigurations.m 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. // Copyright 2020 Google LLC
  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. // http://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. #import "FirebasePerformance/Tests/Unit/Fakes/FPRFakeConfigurations.h"
  15. @interface FPRFakeConfigurations ()
  16. @property(nonatomic) BOOL collectionEnabled;
  17. @property(nonatomic) BOOL autoInstrumentationEnabled;
  18. @property(nonatomic) int perfLogSource;
  19. @property(nonatomic) BOOL perfSdkEnabled;
  20. @property(nonatomic) BOOL perfDiagnosticsEnabled;
  21. @property(nonatomic) float normalTraceSamplingRate;
  22. @property(nonatomic) float networkTraceSamplingRate;
  23. @property(nonatomic) uint32_t foregroundEventCount;
  24. @property(nonatomic) uint32_t foregroundTimelimit;
  25. @property(nonatomic) uint32_t backgroundEventCount;
  26. @property(nonatomic) uint32_t backgroundTimelimit;
  27. @property(nonatomic) uint32_t foregroundNetworkEventCount;
  28. @property(nonatomic) uint32_t foregroundNetworkTimelimit;
  29. @property(nonatomic) uint32_t backgroundNetworkEventCount;
  30. @property(nonatomic) uint32_t backgroundNetworkTimelimit;
  31. @property(nonatomic) float sessionSamplingRate;
  32. @property(nonatomic) uint32_t maxSessionLength;
  33. @property(nonatomic) uint32_t cpuSamplingFrequencyInForeground;
  34. @property(nonatomic) uint32_t cpuSamplingFrequencyInBackground;
  35. @property(nonatomic) uint32_t memorySamplingFrequencyInForeground;
  36. @property(nonatomic) uint32_t memorySamplingFrequencyInBackground;
  37. @end
  38. @implementation FPRFakeConfigurations
  39. - (BOOL)isDataCollectionEnabled {
  40. return self.collectionEnabled;
  41. }
  42. - (BOOL)isInstrumentationEnabled {
  43. return self.autoInstrumentationEnabled;
  44. }
  45. - (int)logSource {
  46. return self.perfLogSource;
  47. }
  48. - (BOOL)sdkEnabled {
  49. return self.perfSdkEnabled;
  50. }
  51. - (BOOL)diagnosticsEnabled {
  52. return self.perfDiagnosticsEnabled;
  53. }
  54. - (float)logTraceSamplingRate {
  55. return self.normalTraceSamplingRate;
  56. }
  57. - (float)logNetworkSamplingRate {
  58. return self.networkTraceSamplingRate;
  59. }
  60. - (uint32_t)foregroundEventCount {
  61. return _foregroundEventCount;
  62. }
  63. - (uint32_t)foregroundEventTimeLimit {
  64. return self.foregroundTimelimit;
  65. }
  66. - (uint32_t)backgroundEventCount {
  67. return _backgroundEventCount;
  68. }
  69. - (uint32_t)backgroundEventTimeLimit {
  70. return self.backgroundTimelimit;
  71. }
  72. - (uint32_t)foregroundNetworkEventCount {
  73. return _foregroundNetworkEventCount;
  74. }
  75. - (uint32_t)foregroundNetworkEventTimeLimit {
  76. return self.foregroundNetworkTimelimit;
  77. }
  78. - (uint32_t)backgroundNetworkEventCount {
  79. return _backgroundNetworkEventCount;
  80. }
  81. - (uint32_t)backgroundNetworkEventTimeLimit {
  82. return self.backgroundNetworkTimelimit;
  83. }
  84. - (float_t)sessionsSamplingPercentage {
  85. return self.sessionSamplingRate;
  86. }
  87. - (uint32_t)maxSessionLengthInMinutes {
  88. return self.maxSessionLength;
  89. }
  90. - (uint32_t)cpuSamplingFrequencyInForegroundInMS {
  91. return self.cpuSamplingFrequencyInForeground;
  92. }
  93. - (uint32_t)cpuSamplingFrequencyInBackgroundInMS {
  94. return self.cpuSamplingFrequencyInBackground;
  95. }
  96. - (uint32_t)memorySamplingFrequencyInForegroundInMS {
  97. return self.memorySamplingFrequencyInForeground;
  98. }
  99. - (uint32_t)memorySamplingFrequencyInBackgroundInMS {
  100. return self.memorySamplingFrequencyInBackground;
  101. }
  102. #pragma mark - Configurations setters
  103. - (void)setDataCollectionEnabled:(BOOL)dataCollectionEnabled {
  104. self.collectionEnabled = dataCollectionEnabled;
  105. }
  106. - (void)setInstrumentationEnabled:(BOOL)instrumentationEnabled {
  107. self.autoInstrumentationEnabled = instrumentationEnabled;
  108. }
  109. - (void)setLogSource:(int)logSource {
  110. self.perfLogSource = logSource;
  111. }
  112. - (void)setSdkEnabled:(BOOL)enabled {
  113. self.perfSdkEnabled = enabled;
  114. }
  115. - (void)setDiagnosticsEnabled:(BOOL)enabled {
  116. self.perfDiagnosticsEnabled = enabled;
  117. }
  118. #pragma mark - Sampling related configurations.
  119. - (void)setTraceSamplingRate:(float)rate {
  120. self.normalTraceSamplingRate = rate;
  121. }
  122. - (void)setNetworkSamplingRate:(float)rate {
  123. self.networkTraceSamplingRate = rate;
  124. }
  125. #pragma mark - Rate limiting related configurations.
  126. - (void)setForegroundTimeLimit:(uint32_t)timeLimit {
  127. self.foregroundTimelimit = timeLimit;
  128. }
  129. - (void)setBackgroundTimeLimit:(uint32_t)timeLimit {
  130. self.backgroundTimelimit = timeLimit;
  131. }
  132. - (void)setForegroundNetworkTimeLimit:(uint32_t)timeLimit {
  133. self.foregroundNetworkTimelimit = timeLimit;
  134. }
  135. - (void)setBackgroundNetworkTimeLimit:(uint32_t)timeLimit {
  136. self.backgroundNetworkTimelimit = timeLimit;
  137. }
  138. #pragma mark - Session related configurations.
  139. - (void)setSessionsSamplingPercentage:(float)rate {
  140. self.sessionSamplingRate = rate;
  141. }
  142. - (void)setMaxSessionLengthInMinutes:(uint32_t)minutes {
  143. self.maxSessionLength = minutes;
  144. }
  145. - (void)setCpuSamplingFrequencyInForegroundInMS:(uint32_t)frequency {
  146. self.cpuSamplingFrequencyInForeground = frequency;
  147. }
  148. - (void)setCpuSamplingFrequencyInBackgroundInMS:(uint32_t)frequency {
  149. self.cpuSamplingFrequencyInBackground = frequency;
  150. }
  151. - (void)setMemorySamplingFrequencyInForegroundInMS:(uint32_t)frequency {
  152. self.memorySamplingFrequencyInForeground = frequency;
  153. }
  154. - (void)setMemorySamplingFrequencyInBackgroundInMS:(uint32_t)frequency {
  155. self.memorySamplingFrequencyInBackground = frequency;
  156. }
  157. #pragma mark - FLL related configurations.
  158. - (float_t)fllTransportPercentage {
  159. return self.fllTransportPercentageValue;
  160. }
  161. @end