BaseNSLogging.m 2.2 KB

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