Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
robbiehanson committed Jun 2, 2010
1 parent 4de8e2a commit 79d1316
Show file tree
Hide file tree
Showing 150 changed files with 47,730 additions and 0 deletions.
12 changes: 12 additions & 0 deletions Benchmarking/BaseNSLogging.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#import <Foundation/Foundation.h>


@interface BaseNSLogging : NSObject

+ (void)speedTest0;
+ (void)speedTest1;
+ (void)speedTest2;
+ (void)speedTest3;
+ (void)speedTest4;

@end
92 changes: 92 additions & 0 deletions Benchmarking/BaseNSLogging.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
#import "BaseNSLogging.h"
#import "PerformanceTesting.h"

#define DDLogVerbose NSLog
#define DDLogInfo NSLog
#define DDLogWarn NSLog
#define DDLogError NSLog

#define FILENAME @"BaseNSLogging " // Trailing space to match exactly the others in length


@implementation BaseNSLogging

+ (void)speedTest0
{
// Log statements that will not be executed due to log level

for (NSUInteger i = 0; i < SPEED_TEST_0_COUNT; i++)
{
DDLogVerbose(@"%@: SpeedTest0 - %lu", FILENAME, (unsigned long)i);
}
}

+ (void)speedTest1
{
// Log statements that will be executed asynchronously

for (NSUInteger i = 0; i < SPEED_TEST_1_COUNT; i++)
{
DDLogWarn(@"%@: SpeedTest1 - %lu", FILENAME, (unsigned long)i);
}
}

+ (void)speedTest2
{
// Log statements that will be executed synchronously

for (NSUInteger i = 0; i < SPEED_TEST_2_COUNT; i++)
{
DDLogError(@"%@: SpeedTest2 - %lu", FILENAME, (unsigned long)i);
}
}

+ (void)speedTest3
{
// Even Spread:
//
// 25% - Not executed due to log level
// 50% - Executed asynchronously
// 25% - Executed synchronously

for (NSUInteger i = 0; i < SPEED_TEST_3_COUNT; i++)
{
DDLogError(@"%@: SpeedTest3A - %lu", FILENAME, (unsigned long)i);
}
for (NSUInteger i = 0; i < SPEED_TEST_3_COUNT; i++)
{
DDLogWarn(@"%@: SpeedTest3B - %lu", FILENAME, (unsigned long)i);
}
for (NSUInteger i = 0; i < SPEED_TEST_3_COUNT; i++)
{
DDLogInfo(@"%@: SpeedTest3C - %lu", FILENAME, (unsigned long)i);
}
for (NSUInteger i = 0; i < SPEED_TEST_3_COUNT; i++)
{
DDLogVerbose(@"%@: SpeedTest3D - %lu", FILENAME, (unsigned long)i);
}
}

+ (void)speedTest4
{
// Custom Spread

for (NSUInteger i = 0; i < SPEED_TEST_4_ERROR_COUNT; i++)
{
DDLogError(@"%@: SpeedTest4A - %lu", FILENAME, (unsigned long)i);
}
for (NSUInteger i = 0; i < SPEED_TEST_4_WARN_COUNT; i++)
{
DDLogWarn(@"%@: SpeedTest4B - %lu", FILENAME, (unsigned long)i);
}
for (NSUInteger i = 0; i < SPEED_TEST_4_INFO_COUNT; i++)
{
DDLogInfo(@"%@: SpeedTest4C - %lu", FILENAME, (unsigned long)i);
}
for (NSUInteger i = 0; i < SPEED_TEST_4_VERBOSE_COUNT; i++)
{
DDLogVerbose(@"%@: SpeedTest4D - %lu", FILENAME, (unsigned long)i);
}
}

@end
12 changes: 12 additions & 0 deletions Benchmarking/DynamicLogging.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#import <Foundation/Foundation.h>


@interface DynamicLogging : NSObject

+ (void)speedTest0;
+ (void)speedTest1;
+ (void)speedTest2;
+ (void)speedTest3;
+ (void)speedTest4;

@end
101 changes: 101 additions & 0 deletions Benchmarking/DynamicLogging.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
#import "DynamicLogging.h"
#import "PerformanceTesting.h"
#import "DDLog.h"

#define FILENAME @"DynamicLogging"

// Debug levels: off, error, warn, info, verbose
static int ddLogLevel = LOG_LEVEL_WARN; // NOT CONST


@implementation DynamicLogging

+ (int)ddLogLevel
{
return ddLogLevel;
}

+ (void)ddSetLogLevel:(int)logLevel
{
ddLogLevel = logLevel;
}

+ (void)speedTest0
{
// Log statements that will not be executed due to log level

for (NSUInteger i = 0; i < SPEED_TEST_0_COUNT; i++)
{
DDLogVerbose(@"%@: SpeedTest0 - %lu", FILENAME, (unsigned long)i);
}
}

+ (void)speedTest1
{
// Log statements that will be executed asynchronously

for (NSUInteger i = 0; i < SPEED_TEST_1_COUNT; i++)
{
DDLogWarn(@"%@: SpeedTest1 - %lu", FILENAME, (unsigned long)i);
}
}

+ (void)speedTest2
{
// Log statements that will be executed synchronously

for (NSUInteger i = 0; i < SPEED_TEST_2_COUNT; i++)
{
DDLogError(@"%@: SpeedTest2 - %lu", FILENAME, (unsigned long)i);
}
}

+ (void)speedTest3
{
// Even Spread:
//
// 25% - Not executed due to log level
// 50% - Executed asynchronously
// 25% - Executed synchronously

for (NSUInteger i = 0; i < SPEED_TEST_3_COUNT; i++)
{
DDLogError(@"%@: SpeedTest3A - %lu", FILENAME, (unsigned long)i);
}
for (NSUInteger i = 0; i < SPEED_TEST_3_COUNT; i++)
{
DDLogWarn(@"%@: SpeedTest3B - %lu", FILENAME, (unsigned long)i);
}
for (NSUInteger i = 0; i < SPEED_TEST_3_COUNT; i++)
{
DDLogInfo(@"%@: SpeedTest3C - %lu", FILENAME, (unsigned long)i);
}
for (NSUInteger i = 0; i < SPEED_TEST_3_COUNT; i++)
{
DDLogVerbose(@"%@: SpeedTest3D - %lu", FILENAME, (unsigned long)i);
}
}

+ (void)speedTest4
{
// Custom Spread

for (NSUInteger i = 0; i < SPEED_TEST_4_ERROR_COUNT; i++)
{
DDLogError(@"%@: SpeedTest4A - %lu", FILENAME, (unsigned long)i);
}
for (NSUInteger i = 0; i < SPEED_TEST_4_WARN_COUNT; i++)
{
DDLogWarn(@"%@: SpeedTest4B - %lu", FILENAME, (unsigned long)i);
}
for (NSUInteger i = 0; i < SPEED_TEST_4_INFO_COUNT; i++)
{
DDLogInfo(@"%@: SpeedTest4C - %lu", FILENAME, (unsigned long)i);
}
for (NSUInteger i = 0; i < SPEED_TEST_4_VERBOSE_COUNT; i++)
{
DDLogVerbose(@"%@: SpeedTest4D - %lu", FILENAME, (unsigned long)i);
}
}

@end
19 changes: 19 additions & 0 deletions Benchmarking/PerformanceTesting.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#import <Foundation/Foundation.h>

#define SPEED_TEST_0_COUNT 1000 // Total log statements
#define SPEED_TEST_1_COUNT 1000 // Total log statements
#define SPEED_TEST_2_COUNT 1000 // Total log statements
#define SPEED_TEST_3_COUNT 250 // Per log level (multiply by 4 to get total)

#define SPEED_TEST_4_VERBOSE_COUNT 900
#define SPEED_TEST_4_INFO_COUNT 000
#define SPEED_TEST_4_WARN_COUNT 000
#define SPEED_TEST_4_ERROR_COUNT 100

// Further documentation on these tests may be found in the implementation file.

@interface PerformanceTesting : NSObject

+ (void)startPerformanceTests;

@end
Loading

0 comments on commit 79d1316

Please sign in to comment.