Files
MacPass/MacPassTests/KPKTestPerformance.m
michael starke 5e0e8f0aeb Added simple performance test
Signed-off-by: michael starke <michael.starke@hicknhack-software.com>
2015-10-23 19:29:50 +02:00

58 lines
1.3 KiB
Objective-C

//
// KPKTestPerformance.m
// MacPass
//
// Created by Michael Starke on 21/10/15.
// Copyright © 2015 HicknHack Software GmbH. All rights reserved.
//
#import <XCTest/XCTest.h>
#import "KPKEntry.h"
#import "KPKAttribute.h"
#import "KPKFormat.h"
NSUInteger const _kKPKEntryCount = 1000;
@interface KPKTestPerformance : XCTestCase {
KPKEntry *testEntry;
}
@end
@implementation KPKTestPerformance
- (void)setUp {
[super setUp];
testEntry = [[KPKEntry alloc] init];
NSUInteger count = _kKPKEntryCount;
while(count-- > 0) {
[testEntry addCustomAttribute:[[KPKAttribute alloc] initWithKey:@(count).stringValue
value:@(count).stringValue]];
}
}
- (void)tearDown {
// Put teardown code here. This method is called after the invocation of each test method in the class.
[super tearDown];
}
- (void)testAttributeLookupPerformanceA {
[self measureBlock:^{
[testEntry customAttributeForKey:@(0).stringValue];
}];
}
- (void)testAttributeLookupPerformanceB {
[self measureBlock:^{
[testEntry customAttributeForKey:@(_kKPKEntryCount - 1).stringValue];
}];
}
- (void)testAttributeLookupPerformanceC {
[self measureBlock:^{
[testEntry customAttributeForKey:kKPKTitleKey];
}];
}
@end