[cost] add objc test for customized_class and blocks

Summary: Add objc test for customized class and blocks. Mostly sanity test.

Reviewed By: ezgicicek

Differential Revision: D22043918

fbshipit-source-id: 917deeea7
master
Qianyi Shu 5 years ago committed by Facebook GitHub Bot
parent d91d40bee8
commit 149e1879ce

@ -0,0 +1,19 @@
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#import <Foundation/Foundation.h>
NSInteger block_multiply_array_linear_FN(NSArray* array) {
NSInteger (^sum_array)(NSArray*) = ^(NSArray* array) {
NSInteger n = 0;
for (id value in array) {
n += [value integerValue];
}
return n;
};
return sum_array(array);
}

@ -58,6 +58,8 @@ codetoanalyze/objc/performance/araii.m, Araii.dealloc, 4, OnUIThread:false, []
codetoanalyze/objc/performance/araii.m, Araii.initWithBuffer, 15, OnUIThread:false, []
codetoanalyze/objc/performance/araii.m, Araii.setBuffer:, 4, OnUIThread:false, []
codetoanalyze/objc/performance/araii.m, memory_leak_raii_main, 18, OnUIThread:false, []
codetoanalyze/objc/performance/block.m, block_multiply_array_linear_FN, 6, OnUIThread:false, []
codetoanalyze/objc/performance/block.m, objc_blockblock_multiply_array_linear_FN_1, 17, OnUIThread:false, []
codetoanalyze/objc/performance/break.m, break_constant_FP, 8 + 5 ⋅ p + 2 ⋅ (1+max(0, p)), OnUIThread:false, [{1+max(0, p)},call to break_loop,Loop at line 10, column 3,{p},call to break_loop,Loop at line 10, column 3]
codetoanalyze/objc/performance/break.m, break_loop, 5 + 5 ⋅ p + 2 ⋅ (1+max(0, p)), OnUIThread:false, [{1+max(0, p)},Loop at line 10, column 3,{p},Loop at line 10, column 3]
codetoanalyze/objc/performance/break.m, break_loop_with_t, 7 + 5 ⋅ p + 2 ⋅ (1+max(0, p)), OnUIThread:false, [{1+max(0, p)},Loop at line 22, column 3,{p},Loop at line 22, column 3]
@ -106,6 +108,19 @@ codetoanalyze/objc/performance/exit.m, compute_exit_unreachable, ⊥, OnUIThrea
codetoanalyze/objc/performance/exit.m, exit_unreachable, ⊥, OnUIThread:false, [Unreachable node]
codetoanalyze/objc/performance/exit.m, inline_exit_unreachable_FP, 3 ⋅ p + 2 ⋅ (1+max(0, p)), OnUIThread:false, [{1+max(0, p)},Loop at line 30, column 3,{p},Loop at line 30, column 3]
codetoanalyze/objc/performance/exit.m, linear, 3 + 3 ⋅ p + 2 ⋅ (1+max(0, p)), OnUIThread:false, [{1+max(0, p)},Loop at line 18, column 3,{p},Loop at line 18, column 3]
codetoanalyze/objc/performance/field_access.m, Person.add_income_constant:, 12, OnUIThread:false, []
codetoanalyze/objc/performance/field_access.m, Person.bank_account, 4, OnUIThread:false, []
codetoanalyze/objc/performance/field_access.m, Person.dealloc, 4, OnUIThread:false, []
codetoanalyze/objc/performance/field_access.m, Person.init_with_name_constant:, 22, OnUIThread:false, []
codetoanalyze/objc/performance/field_access.m, Person.name, 4, OnUIThread:false, []
codetoanalyze/objc/performance/field_access.m, Person.setBank_account:, 4, OnUIThread:false, []
codetoanalyze/objc/performance/field_access.m, Person.setName:, 4, OnUIThread:false, []
codetoanalyze/objc/performance/field_access.m, Person.species_name_constant, 3, OnUIThread:false, []
codetoanalyze/objc/performance/field_access.m, Test1.dealloc, 1, OnUIThread:false, []
codetoanalyze/objc/performance/field_access.m, Test1.setX:, 4, OnUIThread:false, []
codetoanalyze/objc/performance/field_access.m, Test1.x, 4, OnUIThread:false, []
codetoanalyze/objc/performance/field_access.m, create_common_person_constant, 44, OnUIThread:false, []
codetoanalyze/objc/performance/field_access.m, iterate_upto_field_size_linear, 3 + 3 ⋅ test->_x.ub + 6 ⋅ (1+max(0, test->_x.ub)), OnUIThread:false, [{1+max(0, test->_x.ub)},Loop at line 19, column 3,{test->_x.ub},Loop at line 19, column 3]
codetoanalyze/objc/performance/instantiate.m, do_2_times_constant, 20, OnUIThread:false, []
codetoanalyze/objc/performance/instantiate.m, do_half_m2_times_quadratic, 3 + 5 ⋅ (m - 1) × m + 7 ⋅ m + 2 ⋅ m × (max(1, m)) + 2 ⋅ (1+max(0, m)), OnUIThread:false, [{1+max(0, m)},Loop at line 28, column 3,{max(1, m)},call to do_n_times,Loop at line 12, column 3,{m},Loop at line 28, column 3,{m},Loop at line 28, column 3,{m - 1},call to do_n_times,Loop at line 12, column 3]
codetoanalyze/objc/performance/instantiate.m, do_m2_times_quadratic, 3 + 7 ⋅ m + 5 ⋅ m × m + 2 ⋅ m × (1+max(0, m)) + 2 ⋅ (1+max(0, m)), OnUIThread:false, [{1+max(0, m)},Loop at line 21, column 3,{1+max(0, m)},call to do_n_times,Loop at line 12, column 3,{m},call to do_n_times,Loop at line 12, column 3,{m},Loop at line 21, column 3]

@ -0,0 +1,58 @@
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#import <Foundation/Foundation.h>
@interface Test1 : NSObject
@property NSInteger x;
@end
@implementation Test1
@end
void iterate_upto_field_size_linear(Test1* test) {
for (int ci = 0; ci < test.x; ci++) {
}
}
@interface Person : NSObject
@property(nonatomic) NSString* name;
@property(nonatomic) NSUInteger bank_account;
- (id)init_with_name:(NSString*)name;
- (void)add_income:(NSUInteger)income;
+ (NSString*)species_name;
@end
@implementation Person
- (id)init_with_name_constant:(NSString*)name {
self = [super init];
if (self) {
self.name = name;
self.bank_account = (NSUInteger) @0;
}
return self;
}
- (void)add_income_constant:(NSUInteger)income {
self.bank_account += income;
}
+ (NSString*)species_name_constant {
return @"Human";
}
@end
NSString* create_common_person_constant() {
Person* person = [[Person alloc] init_with_name_constant:@"John Smith"];
[person add_income_constant:(NSUInteger) @100];
return [Person species_name_constant];
}

@ -41,6 +41,7 @@ codetoanalyze/objc/performance/NSString.m, replace_linear_FP, 0, INFINITE_EXECUT
codetoanalyze/objc/performance/NSString.m, replace_linear_FP, 2, INTEGER_OVERFLOW_U5, no_bucket, ERROR, [<LHS trace>,Unknown value from: NSString.length,Binary operation: ([0, +oo] + 1):signed32]
codetoanalyze/objc/performance/NSString.m, substring_no_end_linear_FP, 0, INFINITE_EXECUTION_TIME, no_bucket, ERROR, [Unbounded loop,Loop at line 81, column 3]
codetoanalyze/objc/performance/NSString.m, substring_no_end_linear_FP, 2, INTEGER_OVERFLOW_U5, no_bucket, ERROR, [<LHS trace>,Unknown value from: NSString.length,Binary operation: ([0, +oo] + 1):signed32]
codetoanalyze/objc/performance/block.m, objc_blockblock_multiply_array_linear_FN_1, 3, INTEGER_OVERFLOW_U5, no_bucket, ERROR, [<LHS trace>,Assignment,<RHS trace>,Unknown value from: NSNumber.integerValue,Binary operation: ([-oo, +oo] + [-oo, +oo]):signed64]
codetoanalyze/objc/performance/compound_loop_guard.m, compound_while, 3, CONDITION_ALWAYS_TRUE, no_bucket, WARNING, [Here]
codetoanalyze/objc/performance/compound_loop_guard.m, nested_while_and_or_constant, 3, CONDITION_ALWAYS_TRUE, no_bucket, WARNING, [Here]
codetoanalyze/objc/performance/compound_loop_guard.m, nested_while_and_or_constant, 3, CONDITION_ALWAYS_TRUE, no_bucket, WARNING, [Here]
@ -68,6 +69,7 @@ codetoanalyze/objc/performance/cost_test_deps.m, two_loops, 5, INTEGER_OVERFLOW_
codetoanalyze/objc/performance/exit.m, call_exit_unreachable, 0, EXECUTION_TIME_UNREACHABLE_AT_EXIT, no_bucket, ERROR, [Unreachable node]
codetoanalyze/objc/performance/exit.m, compute_exit_unreachable, 0, EXECUTION_TIME_UNREACHABLE_AT_EXIT, no_bucket, ERROR, [Unreachable node]
codetoanalyze/objc/performance/exit.m, exit_unreachable, 0, EXECUTION_TIME_UNREACHABLE_AT_EXIT, no_bucket, ERROR, [Unreachable node]
codetoanalyze/objc/performance/field_access.m, create_common_person_constant, 2, INTEGER_OVERFLOW_U5, no_bucket, ERROR, [Unknown value from: NSNumber.numberWithInt:,Call,<LHS trace>,Parameter `self->_bank_account`,Call,Parameter `self->_bank_account`,Assignment,<RHS trace>,Parameter `income`,Binary operation: ([0, +oo] + [0, +oo]):unsigned64 by call to `Person.add_income_constant:` ]
codetoanalyze/objc/performance/invariant.m, while_infinite_FN, 2, CONDITION_ALWAYS_TRUE, no_bucket, WARNING, [Here]
codetoanalyze/objc/performance/loops.m, if_in_loop, 5, INTEGER_OVERFLOW_L5, no_bucket, ERROR, [<LHS trace>,Assignment,Binary operation: ([0, +oo] + 1):signed32]
codetoanalyze/objc/performance/switch_continue.m, test_switch_FN, 3, CONDITION_ALWAYS_TRUE, no_bucket, WARNING, [Here]

Loading…
Cancel
Save