BaseNSLogging.m 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. #import "BaseNSLogging.h"
  2. #import "PerformanceTesting.h"
  3. #define DDLogVerbose NSLog
  4. #define DDLogInfo NSLog
  5. #define DDLogWarn NSLog
  6. #define DDLogError NSLog
  7. #define FILENAME @"BaseNSLogging " // Trailing space to match exactly the others in length
  8. @implementation BaseNSLogging
  9. + (void)speedTest0
  10. {
  11. // Log statements that will not be executed due to log level
  12. for (NSUInteger i = 0; i < SPEED_TEST_0_COUNT; i++)
  13. {
  14. DDLogVerbose(@"%@: SpeedTest0 - %lu", FILENAME, (unsigned long)i);
  15. }
  16. }
  17. + (void)speedTest1
  18. {
  19. // Log statements that will be executed asynchronously
  20. for (NSUInteger i = 0; i < SPEED_TEST_1_COUNT; i++)
  21. {
  22. DDLogWarn(@"%@: SpeedTest1 - %lu", FILENAME, (unsigned long)i);
  23. }
  24. }
  25. + (void)speedTest2
  26. {
  27. // Log statements that will be executed synchronously
  28. for (NSUInteger i = 0; i < SPEED_TEST_2_COUNT; i++)
  29. {
  30. DDLogError(@"%@: SpeedTest2 - %lu", FILENAME, (unsigned long)i);
  31. }
  32. }
  33. + (void)speedTest3
  34. {
  35. // Even Spread:
  36. //
  37. // 25% - Not executed due to log level
  38. // 50% - Executed asynchronously
  39. // 25% - Executed synchronously
  40. for (NSUInteger i = 0; i < SPEED_TEST_3_COUNT; i++)
  41. {
  42. DDLogError(@"%@: SpeedTest3A - %lu", FILENAME, (unsigned long)i);
  43. }
  44. for (NSUInteger i = 0; i < SPEED_TEST_3_COUNT; i++)
  45. {
  46. DDLogWarn(@"%@: SpeedTest3B - %lu", FILENAME, (unsigned long)i);
  47. }
  48. for (NSUInteger i = 0; i < SPEED_TEST_3_COUNT; i++)
  49. {
  50. DDLogInfo(@"%@: SpeedTest3C - %lu", FILENAME, (unsigned long)i);
  51. }
  52. for (NSUInteger i = 0; i < SPEED_TEST_3_COUNT; i++)
  53. {
  54. DDLogVerbose(@"%@: SpeedTest3D - %lu", FILENAME, (unsigned long)i);
  55. }
  56. }
  57. + (void)speedTest4
  58. {
  59. // Custom Spread
  60. for (NSUInteger i = 0; i < SPEED_TEST_4_ERROR_COUNT; i++)
  61. {
  62. DDLogError(@"%@: SpeedTest4A - %lu", FILENAME, (unsigned long)i);
  63. }
  64. for (NSUInteger i = 0; i < SPEED_TEST_4_WARN_COUNT; i++)
  65. {
  66. DDLogWarn(@"%@: SpeedTest4B - %lu", FILENAME, (unsigned long)i);
  67. }
  68. for (NSUInteger i = 0; i < SPEED_TEST_4_INFO_COUNT; i++)
  69. {
  70. DDLogInfo(@"%@: SpeedTest4C - %lu", FILENAME, (unsigned long)i);
  71. }
  72. for (NSUInteger i = 0; i < SPEED_TEST_4_VERBOSE_COUNT; i++)
  73. {
  74. DDLogVerbose(@"%@: SpeedTest4D - %lu", FILENAME, (unsigned long)i);
  75. }
  76. }
  77. @end